From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 352F01F453 for ; Fri, 18 Jan 2019 14:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727458AbfAROTK (ORCPT ); Fri, 18 Jan 2019 09:19:10 -0500 Received: from mout.gmx.net ([212.227.17.22]:60377 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727080AbfAROTJ (ORCPT ); Fri, 18 Jan 2019 09:19:09 -0500 Received: from [10.49.182.9] ([95.208.59.217]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LgeFd-1hXZWR0jzx-00nzCJ; Fri, 18 Jan 2019 15:19:06 +0100 Date: Fri, 18 Jan 2019 15:18:50 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Junio C Hamano cc: Johannes Schindelin via GitGitGadget , git@vger.kernel.org Subject: Re: [PATCH 2/4] rebase: avoid double reflog entry when switching branches In-Reply-To: Message-ID: References: <4c5f87b9dc245bf27785aa5559d4b35d87c4bcbf.1545398254.git.gitgitgadget@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:KeZPWTkxxxIBZGth7ebk/mzk7No8cQ5WydOuChyRSiWNAE05KDg cGxcBoca0RdMA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2YT6p45Hdn/3FL+JnkO61qiG0WND9avPuW8WfU xcmxgxlhuNq6XidmqdXd0Cj49YedAKUI0UFLdCJf/nX7gCdqzdEcVD4EXlbjRTUJnpy3U+FHk f5Ysqk0JuAg== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Junio, On Fri, 4 Jan 2019, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" > writes: > > > From: Johannes Schindelin > > > > 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. > > Ah, in the original sequence, HEAD is updated twice, leaving two > reflog entries for HEAD (and one for the underlying "switch_to" > branch by virtue of REF_UPDATE_VIA_HEAD). In the new sequence, > update_ref() updates the underlying "switch_to" and then HEAD, so > we'd get one reflog entry for each of them. > > Makes sense. s/let's avoid a double entry/& in HEAD's reflog/ would > have avoided wasting reader's time who needlessly wondered where > that redundancy came from, though. Will fix the commit message. Thanks! Dscho > > > > > Signed-off-by: Johannes Schindelin > > --- > > builtin/rebase.c | 7 ++++--- > > 1 file 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: >