From 2147f844ed13fa5052161d38f8cf7dca6f83c06e Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Tue, 24 Jul 2012 13:17:03 +0100 Subject: rebase -i: handle fixup of root commit correctly There is a bug with git rebase -i --root when a fixup or squash line is applied to the new root. We attempt to amend the commit onto which they apply with git reset --soft HEAD^ followed by a normal commit. Unlike a real commit --amend, this sequence will fail against a root commit as it has no parent. Fix rebase -i to use commit --amend for fixup and squash instead, and add a test for the case of a fixup of the root commit. Signed-off-by: Chris Webb Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 060f9d87d2..ef2d631379 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -786,4 +786,12 @@ test_expect_success 'rebase -i --root temporary sentinel commit' ' git rebase --abort ' +test_expect_success 'rebase -i --root fixup root commit' ' + git checkout B && + FAKE_LINES="1 fixup 2" git rebase -i --root && + test A = $(git cat-file commit HEAD | sed -ne \$p) && + test B = $(git show HEAD:file1) && + test 0 = $(git cat-file commit HEAD | grep -c ^parent\ ) +' + test_done -- cgit v1.2.1