Skip to content

Commit 435fd5c

Browse files
dschoGit for Windows Build Agent
authored andcommitted
built-in rebase: no need to check out onto twice
In the case that the rebase boils down to a fast-forward, the built-in rebase reset the working tree twice: once to start the rebase at `onto`, then realizing that the original (pre-rebase) HEAD was an ancestor and we basically already fast-forwarded to the post-rebase HEAD, `reset_head()` was called to update the original ref and to point HEAD back to it. That second `reset_head()` call does not need to touch the working tree, though, as it does not change the actual tip commit (and therefore the working tree should stay unchanged anyway): only the ref needs to be updated (because the rebase detached the HEAD, and we want to go back to the branch on which the rebase was started). But that second `reset_head()` was called without the flag to leave the working tree alone (the reason: when that call was introduced, that flag was not yet even thought of). Let's avoid that unnecessary work by passing that flag. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent eb8503d commit 435fd5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/rebase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,8 +1776,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
17761776
strbuf_addf(&msg, "rebase finished: %s onto %s",
17771777
options.head_name ? options.head_name : "detached HEAD",
17781778
oid_to_hex(&options.onto->object.oid));
1779-
reset_head(NULL, "Fast-forwarded", options.head_name, 0,
1780-
"HEAD", msg.buf);
1779+
reset_head(NULL, "Fast-forwarded", options.head_name,
1780+
RESET_HEAD_REFS_ONLY, "HEAD", msg.buf);
17811781
strbuf_release(&msg);
17821782
ret = !!finish_rebase(&options);
17831783
goto cleanup;

0 commit comments

Comments
 (0)