Skip to content

Commit 0115e03

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb40429 commit 0115e03

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

t/t6050-replace.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,32 @@ test_expect_success GPG '--graft on a commit with a mergetag' '
444444
git replace -d $HASH10
445445
'
446446

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+
447475
test_done

0 commit comments

Comments
 (0)