public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Bence Ferdinandy <bence@ferdinandy.com>
Cc: git@vger.kernel.org, johannes.schindelin@gmx.de,
	cc@mail.ferdinandy.com,
	/tmp/FUboFpyPuH/0001-fetch-set-head-with-set-head-option.patch@mail.ferdinandy.com
Subject: Re: [RFC PATCH 1/2] fetch: set-head with --set-head option
Date: Wed, 11 Sep 2024 02:54:06 -0400	[thread overview]
Message-ID: <20240911065406.GC1538586@coredump.intra.peff.net> (raw)
In-Reply-To: <20240910203129.2251090-2-bence@ferdinandy.com>

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).

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.

-Peff

  reply	other threads:[~2024-09-11  6:54 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 [this message]
2024-09-11 12:16     ` Bence Ferdinandy
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=20240911065406.GC1538586@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=/tmp/FUboFpyPuH/0001-fetch-set-head-with-set-head-option.patch@mail.ferdinandy.com \
    --cc=bence@ferdinandy.com \
    --cc=cc@mail.ferdinandy.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /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