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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2018-12-01 22:38:39 +01:00
parent 7a9a41596b
commit 6471d9fa36

View File

@@ -469,10 +469,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: