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@xxxxxx> --- On Tue, 24 Jul 2007, Uwe Kleine-K?nig wrote: > Johannes Schindelin wrote: > > > I'd appreciate if you prepared a patch with better > > explanations, and also reviewed the man page, if it is in good > > shape (and does not lie about the current behaviour). > > It's on my todo list, but not the top item for git. Please come around to do it. > In the mean-time I found another nuisance: > > [outlines the test case provided in this patch] It would have been a bit less work for me, if you would have used t/trash/ instead of /tmp/, and provided a patch for t3404 for me to work with. Alas, the bug was squashed in 5 minutes. It took me 15 minutes to write (and test) the test. What a difference order can make... git-rebase--interactive.sh | 2 +- t/t3404-rebase-interactive.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 93289c0..78ae51e 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -258,8 +258,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 diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 8206436..817f614 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -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 -- 1.5.3.rc2.42.gda8d