diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-11-21 22:57:42 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-21 22:57:42 +0900 |
commit | ff92463b3cdd99c59ec6fe26271617863d4d4b0c (patch) | |
tree | c03fb4502d4f8301e09b649d61fd9ad840fc96cd | |
parent | Merge branch 'jk/trailer-fixes' into maint (diff) | |
parent | rebase -i: be careful to wrap up fixup/squash chains (diff) | |
download | tgif-ff92463b3cdd99c59ec6fe26271617863d4d4b0c.tar.xz |
Merge branch 'js/rebase-i-autosquash-fix' into maint
"git rebase -i" did not clear the state files correctly when a run
of "squash/fixup" is aborted and then the user manually amended the
commit instead, which has been corrected.
* js/rebase-i-autosquash-fix:
rebase -i: be careful to wrap up fixup/squash chains
rebase -i --autosquash: demonstrate a problem skipping the last squash
-rw-r--r-- | sequencer.c | 17 | ||||
-rwxr-xr-x | t/t3415-rebase-autosquash.sh | 19 |
2 files changed, 33 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c index b9407f3375..c758c1cdcb 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3610,9 +3610,20 @@ static int commit_staged_changes(struct replay_opts *opts, * the commit message and if there was a squash, let the user * edit it. */ - if (is_clean && !oidcmp(&head, &to_amend) && - opts->current_fixup_count > 0 && - file_exists(rebase_path_stopped_sha())) { + if (!is_clean || !opts->current_fixup_count) + ; /* this is not the final fixup */ + else if (oidcmp(&head, &to_amend) || + !file_exists(rebase_path_stopped_sha())) { + /* was a final fixup or squash done manually? */ + if (!is_fixup(peek_command(todo_list, 0))) { + unlink(rebase_path_fixup_msg()); + unlink(rebase_path_squash_msg()); + unlink(rebase_path_current_fixups()); + strbuf_reset(&opts->current_fixups); + opts->current_fixup_count = 0; + } + } else { + /* we are in a fixup/squash chain */ const char *p = opts->current_fixups.buf; int len = opts->current_fixups.len; diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index e364c12622..13f5688135 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -330,4 +330,23 @@ test_expect_success 'wrapped original subject' ' test $base = $parent ' +test_expect_success 'abort last squash' ' + test_when_finished "test_might_fail git rebase --abort" && + test_when_finished "git checkout master" && + + git checkout -b some-squashes && + git commit --allow-empty -m first && + git commit --allow-empty --squash HEAD && + git commit --allow-empty -m second && + git commit --allow-empty --squash HEAD && + + test_must_fail git -c core.editor="grep -q ^pick" \ + rebase -ki --autosquash HEAD~4 && + : do not finish the squash, but resolve it manually && + git commit --allow-empty --amend -m edited-first && + git rebase --skip && + git show >actual && + ! grep first actual +' + test_done |