From: "Bence Ferdinandy" <bence@ferdinandy.com>
To: "Jeff King" <peff@peff.net>
Cc: <git@vger.kernel.org>
Subject: Re: [RFC PATCH 1/2] fetch: set-head with --set-head option
Date: Wed, 11 Sep 2024 14:16:39 +0200 [thread overview]
Message-ID: <D43G52W1ZPWU.2HPFFSQEM3WGV@ferdinandy.com> (raw)
In-Reply-To: <20240911065406.GC1538586@coredump.intra.peff.net>
On Wed Sep 11, 2024 at 08:54, Jeff King <peff@peff.net> wrote:
> On Tue, Sep 10, 2024 at 10:24:58PM +0200, Bence Ferdinandy wrote:
>
> > When cloning a repository refs/remotes/origin/HEAD is set automatically.
> > In contrast, when using init, remote add and fetch to set a remote, one
> > needs to call remote set-head --auto to achieve the same result.
>
> Yes, I think this is a good goal, but...
>
> > diff --git a/builtin/fetch.c b/builtin/fetch.c
> > index b2b5aee5bf..6392314c6a 100644
> > --- a/builtin/fetch.c
> > +++ b/builtin/fetch.c
> > @@ -1961,8 +1961,19 @@ static int fetch_finished(int result, struct strbuf *out,
> > return 0;
> > }
> >
> > -static int fetch_multiple(struct string_list *list, int max_children,
> > - const struct fetch_config *config)
> > +static int run_set_head(const char *name)
> > +{
> > + struct child_process cmd = CHILD_PROCESS_INIT;
> > + strvec_push(&cmd.args, "remote");
> > + strvec_push(&cmd.args, "set-head");
> > + strvec_push(&cmd.args, "--auto");
> > + strvec_push(&cmd.args, name);
> > + cmd.git_cmd = 1;
> > + return run_command(&cmd);
> > +}
>
> ...this is just calling "git remote" to do the real work. Which means
> that git-remote is going to make its own separate connection to the
> server (so slow, but may also require the user to reauthenticate, etc).
And indeed it does authenticate the user twice. I'll change this in a v3 (see
the discussion on v2, I royally messed up CC address on this one :) ).
>
> I think the intent of your patch 2 is that we'd only invoke this when we
> saw a change, which mitigates the impact, but it still seems somewhat
> hacky to me. We already have all of the information we need to do the
> update inside fetch itself.
It was more about not printing slightly misleading information, it did still
always try to get the new information with --auto. With the changes mentioned
in the other thread I'll also rework this a bit.
Best,
Bence
next prev parent reply other threads:[~2024-09-11 12:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 20:24 [RFC PATCH 0/2] set remote/HEAD with fetch Bence Ferdinandy
2024-09-10 20:24 ` [RFC PATCH 1/2] fetch: set-head with --set-head option Bence Ferdinandy
2024-09-11 6:54 ` Jeff King
2024-09-11 12:16 ` Bence Ferdinandy [this message]
2024-09-10 20:24 ` [RFC PATCH 2/2] set-head: do not update if there is no change Bence Ferdinandy
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=D43G52W1ZPWU.2HPFFSQEM3WGV@ferdinandy.com \
--to=bence@ferdinandy.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox