@matheusbsbs / matheus-bagliano / commits / fb47cfbd59
Fork 0

rebase -i: fix interrupted squashing

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>

Johannes Schindelin committed Jul 24, 2007 at 21:43 UTC fb47cfbd59b12ea67e1a5c6a9d0bd665fcae4581
2 files changed +31 -1
git-rebase--interactive.sh
+1 -1
@@ -260,8 +260,8 @@ do_next () {
260 esac
261
262 failed=f
263 - pick_one -n $sha1 || failed=t
263 output git reset --soft HEAD^
264 + pick_one -n $sha1 || failed=t
265 author_script=$(get_author_ident_from_commit $sha1)
266 echo "$author_script" > "$DOTEST"/author-script
267 case $failed in
t/t3404-rebase-interactive.sh
+30
@@ -221,4 +221,34 @@ test_expect_success 'multi-squash only fires up editor once' '
221 test 1 = $(git show | grep ONCE | wc -l)
222 '
223
224 +test_expect_success 'squash works as expected' '
225 + for n in one two three four
226 + do
227 + echo $n >> file$n &&
228 + git add file$n &&
229 + git commit -m $n
230 + done &&
231 + one=$(git rev-parse HEAD~3) &&
232 + FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
233 + test $one = $(git rev-parse HEAD~2)
234 +'
235 +
236 +test_expect_success 'interrupted squash works as expected' '
237 + for n in one two three four
238 + do
239 + echo $n >> conflict &&
240 + git add conflict &&
241 + git commit -m $n
242 + done &&
243 + one=$(git rev-parse HEAD~3) &&
244 + ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
245 + (echo one; echo two; echo four) > conflict &&
246 + git add conflict &&
247 + ! git rebase --continue &&
248 + echo resolved > conflict &&
249 + git add conflict &&
250 + git rebase --continue &&
251 + test $one = $(git rev-parse HEAD~2)
252 +'
253 +
254 test_done