Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matt Hunter <m@lfurio.us>
Cc: git@vger.kernel.org,  Bence Ferdinandy <bence@ferdinandy.com>,
	 Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 0/7] Introduce fetch.followRemoteHEAD config variable
Date: Tue, 16 Jun 2026 16:18:59 -0700	[thread overview]
Message-ID: <xmqqh5n213bw.fsf@gitster.g> (raw)
In-Reply-To: <20260616222606.1003521-1-m@lfurio.us> (Matt Hunter's message of "Tue, 16 Jun 2026 18:25:14 -0400")

Matt Hunter <m@lfurio.us> writes:

> Changes in v2:
>   - Don't die() if the value of fetch.followRemoteHEAD is unrecognized.
>   - Use case-sensitive matching for fetch.followRemoteHEAD values.
>   - Avoid the phrase "configuration option".
>   - Minor documentation wording changes.
>   - Link to v1: https://patch.msgid.link/20260612055947.1499497-1-m@lfurio.us

>     @@ builtin/fetch.c: static int git_fetch_config(const char *k, const char *v,
>      +	if (!strcmp(k, "fetch.followremotehead")) {
>      +		if (!v)
>      +			return config_error_nonbool(k);
>     -+		else if (!strcasecmp(v, "never"))
>     ++		else if (!strcmp(v, "never"))
>      +			fetch_config->follow_remote_head = FOLLOW_REMOTE_NEVER;
>     -+		else if (!strcasecmp(v, "create"))
>     ++		else if (!strcmp(v, "create"))
>      +			fetch_config->follow_remote_head = FOLLOW_REMOTE_CREATE;
>     -+		else if (!strcasecmp(v, "warn"))
>     ++		else if (!strcmp(v, "warn"))
>      +			fetch_config->follow_remote_head = FOLLOW_REMOTE_WARN;
>     -+		else if (!strcasecmp(v, "always"))
>     ++		else if (!strcmp(v, "always"))
>      +			fetch_config->follow_remote_head = FOLLOW_REMOTE_ALWAYS;
>     -+		else
>     -+			die(_("invalid value for '%s': '%s'"),
>     -+				"fetch.followRemoteHEAD", v);
>      +	}

Not dying on an unrecognised value is certainly better than dying,
but shouldn't we at least clear fetch_config->follow_remote_head
to some "unspecified" or "default" value?  What does the existing
parser routine for remote.*.followremotehead do?

Ideally,

 (1) If the "fetch" operation ends up with not needing to consult
     the value of fetch.followRemoteHEAD at all (e.g., it is a
     one-shot fetch that updates no remote-tracking hierarchy, or it
     has a more specific per-remote setting that this variable is
     meant to serve as a mere fallback), any bogus or unknown value
     will not get any warning.

 (2) If fetch.followRemoteHEAD ends up being _used_, and if it has
     an unknown value, we should at least warn "we do not understand
     what you wrote, 'awlays', and we ignore it", or die "we do not
     understand 'reset', perhaps it is from a future version of Git?".

I do not think customization based on git_config() callback like the
above can easily implement such an ideal semantics.

And I suspect that the existing per-remote configuration that this
variable is meant to serve as a fallback definition would not work
in such an ideal way (i.e., even if we are doing one-shot fetch that
does not touch any remote-tracking hierarchies, "git fetch" may warn
if the value is not understood, and when we do need the value, the
code would only warn and does not die), so in that sense this new
code is not making things _worse_, even though it may be spreading
the same badness more widely X-<.

Thanks.

      parent reply	other threads:[~2026-06-16 23:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 16:31 followRemoteHEAD management question Matt Hunter
2026-06-08 23:49 ` Jeff King
2026-06-11  4:12   ` Matt Hunter
2026-06-11  6:01     ` Jeff King
2026-06-11 20:36       ` Bence Ferdinandy
2026-06-12  6:11         ` Matt Hunter
2026-06-12  5:55 ` [PATCH 0/7] Introduce fetch.followRemoteHEAD config option Matt Hunter
2026-06-12  5:55   ` [PATCH 1/7] fetch: fixup set_head advice for warn-if-not-branch Matt Hunter
2026-06-12  5:55   ` [PATCH 2/7] doc: explain fetchRemoteHEADWarn advice Matt Hunter
2026-06-12  5:55   ` [PATCH 3/7] t5510: cleanup remote in followRemoteHEAD dangling ref test Matt Hunter
2026-06-12  5:55   ` [PATCH 4/7] fetch: rename function report_set_head Matt Hunter
2026-06-12  5:55   ` [PATCH 5/7] fetch: refactor do_fetch handling of followRemoteHEAD Matt Hunter
2026-06-12  5:55   ` [PATCH 6/7] fetch: add configuration option fetch.followRemoteHEAD Matt Hunter
2026-06-12 14:00     ` Matt Hunter
2026-06-12 14:17     ` Junio C Hamano
2026-06-13  2:58       ` Matt Hunter
2026-06-12  5:55   ` [PATCH 7/7] fetch: fixup a misaligned comment Matt Hunter
2026-06-16 22:25   ` [PATCH v2 0/7] Introduce fetch.followRemoteHEAD config variable Matt Hunter
2026-06-16 22:25     ` [PATCH v2 1/7] fetch: fixup set_head advice for warn-if-not-branch Matt Hunter
2026-06-16 22:25     ` [PATCH v2 2/7] doc: explain fetchRemoteHEADWarn advice Matt Hunter
2026-06-16 22:25     ` [PATCH v2 3/7] t5510: cleanup remote in followRemoteHEAD dangling ref test Matt Hunter
2026-06-16 22:25     ` [PATCH v2 4/7] fetch: rename function report_set_head Matt Hunter
2026-06-16 22:25     ` [PATCH v2 5/7] fetch: refactor do_fetch handling of followRemoteHEAD Matt Hunter
2026-06-16 22:25     ` [PATCH v2 6/7] fetch: add configuration variable fetch.followRemoteHEAD Matt Hunter
2026-06-16 22:25     ` [PATCH v2 7/7] fetch: fixup a misaligned comment Matt Hunter
2026-06-16 23:18     ` Junio C Hamano [this message]

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=xmqqh5n213bw.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bence@ferdinandy.com \
    --cc=git@vger.kernel.org \
    --cc=m@lfurio.us \
    --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