]> Pileus Git - ~andy/git/commitdiff
rebase -i: fix interrupted squashing
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Tue, 24 Jul 2007 20:43:09 +0000 (21:43 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Jul 2007 17:59:42 +0000 (10:59 -0700)
When a squashing merge failed, the first commit would not be replaced,
due to "git reset --soft" being called with an unmerged index.

Noticed by Uwe Kleine-König.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--interactive.sh
t/t3404-rebase-interactive.sh

index 9a88335c5f7c99f05a76cccbf1badad6903596f9..c9873114991ecfc90fe472b0565aad7022eaa1ff 100755 (executable)
@@ -260,8 +260,8 @@ do_next () {
                esac
 
                failed=f
-               pick_one -n $sha1 || failed=t
                output git reset --soft HEAD^
+               pick_one -n $sha1 || failed=t
                author_script=$(get_author_ident_from_commit $sha1)
                echo "$author_script" > "$DOTEST"/author-script
                case $failed in
index 8206436cc732f809556f957b04f8f9292ac82b3b..817f614cde29f12e01724901e1f0b966a28d04b3 100755 (executable)
@@ -221,4 +221,34 @@ test_expect_success 'multi-squash only fires up editor once' '
        test 1 = $(git show | grep ONCE | wc -l)
 '
 
+test_expect_success 'squash works as expected' '
+       for n in one two three four
+       do
+               echo $n >> file$n &&
+               git add file$n &&
+               git commit -m $n
+       done &&
+       one=$(git rev-parse HEAD~3) &&
+       FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
+       test $one = $(git rev-parse HEAD~2)
+'
+
+test_expect_success 'interrupted squash works as expected' '
+       for n in one two three four
+       do
+               echo $n >> conflict &&
+               git add conflict &&
+               git commit -m $n
+       done &&
+       one=$(git rev-parse HEAD~3) &&
+       ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
+       (echo one; echo two; echo four) > conflict &&
+       git add conflict &&
+       ! git rebase --continue &&
+       echo resolved > conflict &&
+       git add conflict &&
+       git rebase --continue &&
+       test $one = $(git rev-parse HEAD~2)
+'
+
 test_done