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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jan 18, 2019 at 07:09 UTC
5b2237a8761295a0027c7e055e6dfee0e30d5194
1 file changed
+4
-3
builtin/rebase.c
+4
-3
@@ -438,10 +438,11 @@ static int reset_head(struct object_id *oid, const char *action,
438
detach_head ? REF_NO_DEREF : 0,
439
UPDATE_REFS_MSG_ON_ERR);
440
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);
443
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);
446
}
447
448
leave_reset_head: