summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2019-01-18 07:09:25 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-01-18 10:11:45 -0800
commit5b2237a8761295a0027c7e055e6dfee0e30d5194 (patch)
tree62367e3184b84a6caca6acfd24ae977358e6c9e4
parentrebase: move `reset_head()` into a better spot (diff)
downloadtgif-5b2237a8761295a0027c7e055e6dfee0e30d5194.tar.xz
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>
-rw-r--r--builtin/rebase.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index e1dfa74ca8..768bea0da8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -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: