]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: avoid double reflog entry when switching branches
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 18 Jan 2019 15:09:25 +0000 (07:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 18:11:45 +0000 (10:11 -0800)
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>
builtin/rebase.c

index e1dfa74ca85931569a362d11173f6c35be47a434..768bea0da8751228d3aa3acf1943aaefbe19666c 100644 (file)
@@ -438,10 +438,11 @@ static int reset_head(struct object_id *oid, const char *action,
                                 detach_head ? REF_NO_DEREF : 0,
                                 UPDATE_REFS_MSG_ON_ERR);
        else {
-               ret = create_symref("HEAD", switch_to_branch, msg.buf);
+               ret = update_ref(reflog_orig_head, switch_to_branch, oid,
+                                NULL, 0, UPDATE_REFS_MSG_ON_ERR);
                if (!ret)
-                       ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
-                                        UPDATE_REFS_MSG_ON_ERR);
+                       ret = create_symref("HEAD", switch_to_branch,
+                                           reflog_head);
        }
 
 leave_reset_head: