t6050: add tests for listing with --format
This patch adds tests for "git replace -l --format=<fmt>". 'short', 'medium' and 'full' are the only allowed values for <fmt>. 'short' is the same as with no --format option. Tests for 'medium' and 'full' are the most needed. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Dec 11, 2013 at 08:46 UTC
bbbb4afc26cd3d711e07a345d1e5f9eedc68100f
1 file changed
+37
t/t6050-replace.sh
+37
@@ -281,6 +281,43 @@ test_expect_success 'git cat-file --batch works on replace objects' '
281
echo $PARA3 | git cat-file --batch
282
'
283
284
+test_expect_success 'test --format bogus' '
285
+ test_must_fail git replace --format bogus >/dev/null 2>&1
286
+'
287
+
288
+test_expect_success 'test --format short' '
289
+ git replace --format=short >actual &&
290
+ git replace >expected &&
291
+ test_cmp expected actual
292
+'
293
+
294
+test_expect_success 'test --format medium' '
295
+ H1=$(git --no-replace-objects rev-parse HEAD~1) &&
296
+ HT=$(git --no-replace-objects rev-parse HEAD^{tree}) &&
297
+ MYTAG=$(git --no-replace-objects rev-parse mytag) &&
298
+ {
299
+ echo "$H1 -> $BLOB" &&
300
+ echo "$BLOB -> $REPLACED" &&
301
+ echo "$HT -> $H1" &&
302
+ echo "$PARA3 -> $S" &&
303
+ echo "$MYTAG -> $HASH1"
304
+ } | sort >expected &&
305
+ git replace -l --format medium | sort > actual &&
306
+ test_cmp expected actual
307
+'
308
+
309
+test_expect_failure 'test --format full' '
310
+ {
311
+ echo "$H1 (commit) -> $BLOB (blob)" &&
312
+ echo "$BLOB (blob) -> $REPLACED (blob)" &&
313
+ echo "$HT (tree) -> $H1 (commit)" &&
314
+ echo "$PARA3 (commit) -> $S (commit)" &&
315
+ echo "$MYTAG (tag) -> $HASH1 (commit)"
316
+ } | sort >expected &&
317
+ git replace --format=full | sort > actual &&
318
+ test_cmp expected actual
319
+'
320
+
321
test_expect_success 'replace ref cleanup' '
322
test -n "$(git replace)" &&
323
git replace -d $(git replace) &&