rebase -i: be careful to wrap up fixup/squash chains
When an interactive rebase was stopped at the end of a fixup/squash chain, the user might have edited the commit manually before continuing (with either `git rebase --skip` or `git rebase --continue`, it does not really matter which). We need to be very careful to wrap up the fixup/squash chain also in this scenario: otherwise the next fixup/squash chain would try to pick up where the previous one was left. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Johannes Schindelin committed
Aug 31, 2018 at 16:45 UTC
10d2f35436fb350c42bdb8396aee424a9bce44b5
2 files changed
+15
-4
sequencer.c
+14
-3
@@ -3438,9 +3438,20 @@ static int commit_staged_changes(struct replay_opts *opts,
3438
* the commit message and if there was a squash, let the user
3439
* edit it.
3440
*/
3441
- if (is_clean && !oidcmp(&head, &to_amend) &&
3442
- opts->current_fixup_count > 0 &&
3443
- file_exists(rebase_path_stopped_sha())) {
3441
+ if (!is_clean || !opts->current_fixup_count)
3442
+ ; /* this is not the final fixup */
3443
+ else if (oidcmp(&head, &to_amend) ||
3444
+ !file_exists(rebase_path_stopped_sha())) {
3445
+ /* was a final fixup or squash done manually? */
3446
+ if (!is_fixup(peek_command(todo_list, 0))) {
3447
+ unlink(rebase_path_fixup_msg());
3448
+ unlink(rebase_path_squash_msg());
3449
+ unlink(rebase_path_current_fixups());
3450
+ strbuf_reset(&opts->current_fixups);
3451
+ opts->current_fixup_count = 0;
3452
+ }
3453
+ } else {
3454
+ /* we are in a fixup/squash chain */
3455
const char *p = opts->current_fixups.buf;
3456
int len = opts->current_fixups.len;
3457
t/t3415-rebase-autosquash.sh
+1
-1
@@ -330,7 +330,7 @@ test_expect_success 'wrapped original subject' '
330
test $base = $parent
331
'
332
333
-test_expect_failure 'abort last squash' '
333
+test_expect_success 'abort last squash' '
334
test_when_finished "test_might_fail git rebase --abort" &&
335
test_when_finished "git checkout master" &&
336