Skip to content

Commit 1ae77db

Browse files
committed
rebase: avoid double reflog entry when switching branches
When switching a branch *and* updating said branch to a different revision, let's avoid a double entry in HEAD's reflog by first updating the branch and then adjusting the symbolic ref HEAD. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2891774 commit 1ae77db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/rebase.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,11 @@ static int reset_head(struct object_id *oid, const char *action,
440440
detach_head ? REF_NO_DEREF : 0,
441441
UPDATE_REFS_MSG_ON_ERR);
442442
else {
443-
ret = create_symref("HEAD", switch_to_branch, msg.buf);
443+
ret = update_ref(reflog_orig_head, switch_to_branch, oid,
444+
NULL, 0, UPDATE_REFS_MSG_ON_ERR);
444445
if (!ret)
445-
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
446-
UPDATE_REFS_MSG_ON_ERR);
446+
ret = create_symref("HEAD", switch_to_branch,
447+
reflog_head);
447448
}
448449
if (run_hook)
449450
run_hook_le(NULL, "post-checkout",

0 commit comments

Comments
 (0)