Skip to content

Commit 3b125c0

Browse files
committed
Merge branch 'pw/rebase-abort-clean-rewritten' into jch
"git rebase --abort" used to leave refs/rewritten/ when concluding "git rebase -r", which has been corrected. * pw/rebase-abort-clean-rewritten: rebase --abort: cleanup refs/rewritten
2 parents 7d44193 + 812a18b commit 3b125c0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

builtin/rebase.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,16 @@ static int finish_rebase(struct rebase_options *opts)
747747
* user should see them.
748748
*/
749749
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
750-
strbuf_addstr(&dir, opts->state_dir);
751-
remove_dir_recursively(&dir, 0);
752-
strbuf_release(&dir);
750+
if (opts->type == REBASE_INTERACTIVE) {
751+
struct replay_opts replay = REPLAY_OPTS_INIT;
752+
753+
replay.action = REPLAY_INTERACTIVE_REBASE;
754+
sequencer_remove_state(&replay);
755+
} else {
756+
strbuf_addstr(&dir, opts->state_dir);
757+
remove_dir_recursively(&dir, 0);
758+
strbuf_release(&dir);
759+
}
753760

754761
return 0;
755762
}

t/t3430-rebase-merges.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ test_expect_success 'refs/rewritten/* is worktree-local' '
224224
test_cmp_rev HEAD "$(cat wt/b)"
225225
'
226226

227+
test_expect_success '--abort cleans up refs/rewritten' '
228+
git checkout -b abort-cleans-refs-rewritten H &&
229+
GIT_SEQUENCE_EDITOR="echo break >>" git rebase -ir @^ &&
230+
git rev-parse --verify refs/rewritten/onto &&
231+
git rebase --abort &&
232+
test_must_fail git rev-parse --verify refs/rewritten/onto
233+
'
234+
227235
test_expect_success 'post-rewrite hook and fixups work for merges' '
228236
git checkout -b post-rewrite &&
229237
test_commit same1 &&

0 commit comments

Comments
 (0)