Add a test for `git replace --convert-graft-file`
The proof, as the saying goes, lies in the pudding. So here is a regression test that not only demonstrates what the option is supposed to accomplish, but also demonstrates that it does accomplish it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Apr 29, 2018 at 00:44 UTC
0115e030db499853a77c2b92dc8c6a51552009ef
1 file changed
+28
t/t6050-replace.sh
+28
@@ -444,4 +444,32 @@ test_expect_success GPG '--graft on a commit with a mergetag' '
444
git replace -d $HASH10
445
'
446
447
+test_expect_success '--convert-graft-file' '
448
+ git checkout -b with-graft-file &&
449
+ test_commit root2 &&
450
+ git reset --hard root2^ &&
451
+ test_commit root1 &&
452
+ test_commit after-root1 &&
453
+ test_tick &&
454
+ git merge -m merge-root2 root2 &&
455
+
456
+ : add and convert graft file &&
457
+ printf "%s\n%s %s\n\n# comment\n%s\n" \
458
+ $(git rev-parse HEAD^^ HEAD^ HEAD^^ HEAD^2) \
459
+ >.git/info/grafts &&
460
+ git replace --convert-graft-file &&
461
+ test_path_is_missing .git/info/grafts &&
462
+
463
+ : verify that the history is now "grafted" &&
464
+ git rev-list HEAD >out &&
465
+ test_line_count = 4 out &&
466
+
467
+ : create invalid graft file and verify that it is not deleted &&
468
+ test_when_finished "rm -f .git/info/grafts" &&
469
+ echo $EMPTY_BLOB $EMPTY_TREE >.git/info/grafts &&
470
+ test_must_fail git replace --convert-graft-file 2>err &&
471
+ test_i18ngrep "$EMPTY_BLOB $EMPTY_TREE" err &&
472
+ test_i18ngrep "$EMPTY_BLOB $EMPTY_TREE" .git/info/grafts
473
+'
474
+
475
test_done