Skip to content

Commit 5aec927

Browse files
dschogitster
authored andcommitted
built-in rebase --skip/--abort: clean up stale .git/<name> files
The scripted version of the rebase used to execute `git reset --hard` when skipping or aborting. When we ported this to C, we did update the worktree and some reflogs, but we failed to imitate `git reset --hard`'s behavior regarding files in .git/ such as MERGE_HEAD. Let's address this oversight. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69c9220 commit 5aec927

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/rebase.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "revision.h"
2424
#include "commit-reach.h"
2525
#include "rerere.h"
26+
#include "branch.h"
2627

2728
static char const * const builtin_rebase_usage[] = {
2829
N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] "
@@ -1002,6 +1003,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10021003

10031004
if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
10041005
die(_("could not discard worktree changes"));
1006+
remove_branch_state();
10051007
if (read_basic_state(&options))
10061008
exit(1);
10071009
goto run_rebase;
@@ -1019,6 +1021,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10191021
options.head_name, 0, NULL, NULL) < 0)
10201022
die(_("could not move back to %s"),
10211023
oid_to_hex(&options.orig_head));
1024+
remove_branch_state();
10221025
ret = finish_rebase(&options);
10231026
goto cleanup;
10241027
}

0 commit comments

Comments
 (0)