Skip to content

Commit fb6ad24

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 by first updating the branch and then adjusting the symbolic ref HEAD. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9c0554e commit fb6ad24

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
@@ -464,10 +464,11 @@ static int reset_head(struct object_id *oid, const char *action,
464464
detach_head ? REF_NO_DEREF : 0,
465465
UPDATE_REFS_MSG_ON_ERR);
466466
else {
467-
ret = create_symref("HEAD", switch_to_branch, msg.buf);
467+
ret = update_ref(reflog_orig_head, switch_to_branch, oid,
468+
NULL, 0, UPDATE_REFS_MSG_ON_ERR);
468469
if (!ret)
469-
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
470-
UPDATE_REFS_MSG_ON_ERR);
470+
ret = create_symref("HEAD", switch_to_branch,
471+
reflog_head);
471472
}
472473

473474
leave_reset_head:

0 commit comments

Comments
 (0)