Commit 1ab6795
rebase -r: do create merge commit after empty resolution
When a user runs 'git rebase --continue' to conclude a conflicted merge
during a 'git rebase -r' invocation, we do not create a merge commit if
the resolution was empty (i.e. if the index and HEAD are identical). We
simply continue the rebase as if no 'merge' instruction had been given.
This is confusing since all commits from the side branch are absent from
the rebased history. What's more, if that 'merge' is the last
instruction in the todo list, we fail to remove the merge state, such
that running 'git status' shows we are still merging after the rebase
has concluded.
This happens because in 'sequencer.c::commit_staged_changes', we exit
early before calling 'run_git_commit' if 'is_clean' is true, i.e. if
nothing is staged. Fix this by also checking for the presence of
MERGE_HEAD before exiting early, such that we do call 'run_git_commit'
when MERGE_HEAD is present. This also ensures that we unlink
git_path_merge_head later in 'commit_staged_changes' to clear the merge
state.
Make sure to also remove MERGE_HEAD when a merge command fails to start.
We already remove MERGE_MSG since e032abd (rebase: fix rewritten list
for failed pick, 2023-09-06). Removing MERGE_HEAD ensures that in this
situation, upon 'git rebase --continue' we still exit early in
'commit_staged_changes', without calling 'run_git_commit'. This is
already covered by t5407.11, which fails without this change because we
enter 'run_git_commit' and then fail to find 'rebase_path_message'.
Signed-off-by: Philippe Blain <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 683c54c commit 1ab6795
2 files changed
+26
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4349 | 4349 | | |
4350 | 4350 | | |
4351 | 4351 | | |
| 4352 | + | |
4352 | 4353 | | |
4353 | 4354 | | |
4354 | 4355 | | |
| |||
5364 | 5365 | | |
5365 | 5366 | | |
5366 | 5367 | | |
5367 | | - | |
| 5368 | + | |
5368 | 5369 | | |
5369 | 5370 | | |
5370 | 5371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
114 | 138 | | |
115 | 139 | | |
116 | 140 | | |
| |||
0 commit comments