All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: Phillip Wood via GitGitGadget <gitgitgadget@gmail.com>,
	git <git@vger.kernel.org>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH 1/7] rebase --apply: remove duplicated code
Date: Sat, 16 Apr 2022 18:56:09 -0700	[thread overview]
Message-ID: <CABPp-BF2p54rcR9xLyZ34-HBPDw6ip08=0rGs3uH=qqSsn0cRA@mail.gmail.com> (raw)
In-Reply-To: <CAP8UFD25KjNYuMoVb72N2kGmo3yJ0qGgfJn78axc562Z+YhAGQ@mail.gmail.com>

On Thu, Apr 7, 2022 at 1:30 PM Christian Couder
<christian.couder@gmail.com> wrote:
>
> On Tue, Feb 22, 2022 at 6:34 AM Phillip Wood via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> >
> > From: Phillip Wood <phillip.wood@dunelm.org.uk>
> >
> > When we are reattaching HEAD after a fast-forward we can use
> > move_to_original_branch() rather than open coding a copy of that
> > code.
>
> Nit: maybe "rebase --apply: reuse move_to_original_branch()" would be
> a better subject for this patch, as it's more specific.
>
> > The old code appears to handle the case where the rebase is
> > started from a detached HEAD but in fact in that case there is nothing
> > to do as we have already updated HEAD.
> >
> > Note that the removal of "strbuf_release(&msg)" is safe as there is an
> > identical call just above this hunk.
>
> It looks like the removed call is using strbuf_reset(), not strbuf_release().
>
> Actually a call to strbuf_release(&msg) is also removed inside the `if
> (oideq(&merge_base, &options.orig_head)) { ... }` clause, but it
> doesn't look like you are talking about this one.

I think he is talking about that one and specifying why it's okay to
drop that one, and omitted why it was okay to drop the strbuf_reset()
because that one seemed more obvious.

> > Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> > ---
> >  builtin/rebase.c | 11 +----------
> >  1 file changed, 1 insertion(+), 10 deletions(-)
> >
> > diff --git a/builtin/rebase.c b/builtin/rebase.c
> > index e942c300f8c..4832f16e675 100644
> > --- a/builtin/rebase.c
> > +++ b/builtin/rebase.c
> > @@ -1782,19 +1782,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
> >          * If the onto is a proper descendant of the tip of the branch, then
> >          * we just fast-forwarded.
> >          */
> > -       strbuf_reset(&msg);
>
> Yeah, it looks like `msg` isn't used in the function anymore so this
> call can be removed.
>
> >         if (oideq(&merge_base, &options.orig_head)) {
> >                 printf(_("Fast-forwarded %s to %s.\n"),
> >                         branch_name, options.onto_name);
> > -               strbuf_addf(&msg, "rebase finished: %s onto %s",
> > -                       options.head_name ? options.head_name : "detached HEAD",
> > -                       oid_to_hex(&options.onto->object.oid));
> > -               memset(&ropts, 0, sizeof(ropts));
> > -               ropts.branch = options.head_name;
> > -               ropts.flags = RESET_HEAD_REFS_ONLY;
> > -               ropts.head_msg = msg.buf;
> > -               reset_head(the_repository, &ropts);
> > -               strbuf_release(&msg);
> > +               move_to_original_branch(&options);
> >                 ret = finish_rebase(&options);
> >                 goto cleanup;
> >         }
>
> Nice cleanup!

Agreed.

  reply	other threads:[~2022-04-17  1:57 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 11:10 [PATCH 0/7] rebase: make reflog messages independent of the backend Phillip Wood via GitGitGadget
2022-02-21 11:10 ` [PATCH 1/7] rebase --apply: remove duplicated code Phillip Wood via GitGitGadget
2022-04-07 13:35   ` Christian Couder
2022-04-17  1:56     ` Elijah Newren [this message]
2022-02-21 11:10 ` [PATCH 2/7] rebase --merge: fix reflog when continuing Phillip Wood via GitGitGadget
2022-04-07 13:49   ` Christian Couder
2022-04-15 14:00     ` Phillip Wood
2022-04-17  1:57       ` Elijah Newren
2022-02-21 11:10 ` [PATCH 3/7] rebase --merge: fix reflog message after skipping Phillip Wood via GitGitGadget
2022-04-17  1:58   ` Elijah Newren
2022-02-21 11:10 ` [PATCH 4/7] rebase --apply: respect GIT_REFLOG_ACTION Phillip Wood via GitGitGadget
2022-04-07 13:59   ` Christian Couder
2022-04-15 14:03     ` Phillip Wood
2022-02-21 11:10 ` [PATCH 5/7] rebase --apply: make reflog messages match rebase --merge Phillip Wood via GitGitGadget
2022-04-17  2:03   ` Elijah Newren
2022-02-21 11:10 ` [PATCH 6/7] rebase --abort: improve reflog message Phillip Wood via GitGitGadget
2022-04-17  2:07   ` Elijah Newren
2022-02-21 11:10 ` [PATCH 7/7] rebase: cleanup action handling Phillip Wood via GitGitGadget
2022-04-17  2:07   ` Elijah Newren
2022-04-04 15:34 ` Review Request (was Re: [PATCH 0/7] rebase: make reflog messages independent of the backend) Phillip Wood
2022-04-17  2:13   ` Elijah Newren
2022-04-18 18:56     ` Phillip Wood
2022-04-07 14:15 ` [PATCH 0/7] rebase: make reflog messages independent of the backend Christian Couder
2022-04-17  2:09 ` Elijah Newren
2022-04-20  9:56 ` [PATCH v2 0/8] " Phillip Wood via GitGitGadget
2022-04-20  9:56   ` [PATCH v2 1/8] rebase --apply: remove duplicated code Phillip Wood via GitGitGadget
2022-04-20 10:10     ` Ævar Arnfjörð Bjarmason
2022-04-20 18:25     ` Junio C Hamano
2022-04-20 18:39       ` Junio C Hamano
2022-04-20  9:56   ` [PATCH v2 2/8] t3406: rework rebase reflog tests Phillip Wood via GitGitGadget
2022-04-20 20:17     ` Junio C Hamano
2022-04-20  9:56   ` [PATCH v2 3/8] rebase --merge: fix reflog when continuing Phillip Wood via GitGitGadget
2022-04-20  9:56   ` [PATCH v2 4/8] rebase --merge: fix reflog message after skipping Phillip Wood via GitGitGadget
2022-04-20  9:56   ` [PATCH v2 5/8] rebase --apply: respect GIT_REFLOG_ACTION Phillip Wood via GitGitGadget
2022-04-20  9:56   ` [PATCH v2 6/8] rebase --apply: make reflog messages match rebase --merge Phillip Wood via GitGitGadget
2022-04-20 10:22     ` Ævar Arnfjörð Bjarmason
2022-04-20 22:15     ` Junio C Hamano
2022-04-20  9:56   ` [PATCH v2 7/8] rebase --abort: improve reflog message Phillip Wood via GitGitGadget
2022-04-20  9:56   ` [PATCH v2 8/8] rebase: cleanup action handling Phillip Wood via GitGitGadget
2022-04-20 10:34     ` Ævar Arnfjörð Bjarmason
2022-10-12  9:35   ` [PATCH v3 0/8] rebase: make reflog messages independent of the backend Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 1/8] rebase --apply: remove duplicated code Phillip Wood via GitGitGadget
2022-10-12 20:36       ` Junio C Hamano
2022-10-13 18:13         ` Junio C Hamano
2022-10-20  9:50           ` Phillip Wood
2022-10-12  9:35     ` [PATCH v3 2/8] t3406: rework rebase reflog tests Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 3/8] rebase --merge: fix reflog when continuing Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 4/8] rebase --merge: fix reflog message after skipping Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 5/8] rebase --apply: respect GIT_REFLOG_ACTION Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 6/8] rebase --apply: make reflog messages match rebase --merge Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 7/8] rebase --abort: improve reflog message Phillip Wood via GitGitGadget
2022-10-12  9:35     ` [PATCH v3 8/8] rebase: cleanup action handling Phillip Wood via GitGitGadget
2022-10-12 20:37     ` [PATCH v3 0/8] rebase: make reflog messages independent of the backend Junio C Hamano
2022-10-13  8:44       ` Phillip Wood
2022-10-13 15:31         ` Junio C Hamano
2022-10-21  9:21     ` [PATCH v4 " Phillip Wood via GitGitGadget
2022-10-21  9:21       ` [PATCH v4 1/8] t3406: rework rebase reflog tests Phillip Wood via GitGitGadget
2022-10-21  9:21       ` [PATCH v4 2/8] rebase --apply: improve fast-forward reflog message Phillip Wood via GitGitGadget
2022-10-21  9:21       ` [PATCH v4 3/8] rebase --merge: fix reflog when continuing Phillip Wood via GitGitGadget
2022-10-21 17:37         ` Junio C Hamano
2022-10-25 10:08           ` Phillip Wood
2022-10-25 16:11             ` Junio C Hamano
2022-10-26 15:17               ` Phillip Wood
2022-10-26 16:55                 ` Junio C Hamano
2022-10-21  9:21       ` [PATCH v4 4/8] rebase --merge: fix reflog message after skipping Phillip Wood via GitGitGadget
2022-10-21  9:21       ` [PATCH v4 5/8] rebase --apply: respect GIT_REFLOG_ACTION Phillip Wood via GitGitGadget
2022-10-21 17:38         ` Junio C Hamano
2022-10-21  9:21       ` [PATCH v4 6/8] rebase --apply: make reflog messages match rebase --merge Phillip Wood via GitGitGadget
2022-10-21 17:39         ` Junio C Hamano
2022-10-21  9:21       ` [PATCH v4 7/8] rebase --abort: improve reflog message Phillip Wood via GitGitGadget
2022-10-21 17:44         ` Junio C Hamano
2022-10-21  9:21       ` [PATCH v4 8/8] rebase: cleanup action handling Phillip Wood via GitGitGadget
2022-10-21 17:54         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABPp-BF2p54rcR9xLyZ34-HBPDw6ip08=0rGs3uH=qqSsn0cRA@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.