Skip to content

Commit 4c5f87b

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 175dc7d commit 4c5f87b

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
@@ -438,10 +438,11 @@ static int reset_head(struct object_id *oid, const char *action,
438438
detach_head ? REF_NO_DEREF : 0,
439439
UPDATE_REFS_MSG_ON_ERR);
440440
else {
441-
ret = create_symref("HEAD", switch_to_branch, msg.buf);
441+
ret = update_ref(reflog_orig_head, switch_to_branch, oid,
442+
NULL, 0, UPDATE_REFS_MSG_ON_ERR);
442443
if (!ret)
443-
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
444-
UPDATE_REFS_MSG_ON_ERR);
444+
ret = create_symref("HEAD", switch_to_branch,
445+
reflog_head);
445446
}
446447

447448
leave_reset_head:

0 commit comments

Comments
 (0)