git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fetch.c: defer fetch.followRemoteHEAD validation

From
Matt Hunter <m@lfurio.us>
Date
Sep 24, 2026, 07:50 UTC
Message-ID
<DLNDRT2L2DYK.3LCFVZ6URY4G6@lfurio.us>
In-Reply-To
<xmqqwlsdhmvk.fsf@gitster.g>
Colin - thanks for picking this up.

Just wanted to make note of some lingering thoughts of mine from when this config was added. I wouldn't consider these necessary for your patch, though you might agree with the ideas.

On Tue Sep 22, 2026 at 1:32 AM EDT, Junio C Hamano wrote:
Show 17 quoted lines
> Colin Hinton <colinlewishinton@gmail.com> writes:
>
>> +static enum follow_remote_head_settings get_follow_remote_head(const char *setting)
>> +{
>> +	if (!strcmp(setting, "never"))
>> +		return FOLLOW_REMOTE_NEVER;
>> +	else if (!strcmp(setting, "create"))
>> +		return FOLLOW_REMOTE_CREATE;
>> +	else if (!strcmp(setting, "warn"))
>> +		return FOLLOW_REMOTE_WARN;
>> +	else if (!strcmp(setting, "always"))
>> +		return FOLLOW_REMOTE_ALWAYS;
>> +	warning(_("unrecognized fetch.followRemoteHEAD value '%s' ignored"), setting);
>> +	return FOLLOW_REMOTE_UNCONFIGURED;
>> +}
>
> OK.  So unrecognised are treated as unconfigured, just like before.

There was an idea I raised in [1] that didn't really get discussed. That being that we should effectively act like FOLLOW_REMOTE_NEVER is set when the configured value is unrecognized.

The situation I envision is a user porting their .gitconfig file to a system running an older git, that doesn't know about their preferred setting. Given that _something_ is configured, the user obviously doesn't want the default behavior, but that's what they'll get when FOLLOW_REMOTE_UNCONFIGURED is returned.

FOLLOW_REMOTE_NEVER seems like the least suprising action to take when we don't understand the request. And I think this reasoning could apply to remote.foo.followRemoteHEAD as well, if you think it's worth doing here.

Show 40 quoted lines
>
> Make a mental note that do_set_head is flipped on ONLY here in this
> function.
>
>>  			if (follow_remote_head != FOLLOW_REMOTE_NEVER)
>>  				do_set_head = 1;
>>  		}
>
> And later, do_set_head is referenced twice.  Once when preparing the
> transport options to first discover what refs they have (ls-refs)
>
> 	if (do_set_head)
> 		strvec_push(&transport_ls_refs_options.ref_prefixes,
> 			    "HEAD");
>
> and then once more to make a set-head call using follow_remote_head.
>
> 	if (do_set_head) {
> 		/*
> 		 * Way too many cases where this can go wrong so let's just
> 		 * ignore errors and fail silently for now.
> 		 */
> 		set_head(remote_refs, transport->remote, follow_remote_head);
> 	}
>
> Incidentally, after that "lazily turn configuration string into
> follow_remote_head variable" block is left, this is the only place
> that follow_remote_head variable is referenced.
>
> Which suggests to me that we can get rid of do_set_head variable, we
> can initialize follow_remote_head variable to FOLLOW_REMOTE_NEVER,
> and replace these two 
>
> 	if (do_set_head)
>
> with
>
> 	if (follow_remote_head != FOLLOW_REMOTE_NEVER)
>
> and the resulting code may become a tad easier to follow.

It occurred to me a while ago that there's another case in which we might want to skip querying the remote for its HEAD - when FOLLOW_REMOTE_CREATE is in effect, and the remote already has a local HEAD symref. Given that 'create' is the default mode for this setting, it would probably be a valuable save on network and server overhead.

Of course, I think this should probably be its own topic, separate from what this patch is addressing. But if the condition of that 'if' statement is to become more complicated, it might be a good reason to not start duplicating it here.

>
> Hmmm?
1: https://lore.kernel.org/git/DJBVYP58YNTU.LQ7VXFIQE84H@lfurio.us/
Previous: Colin HintonNext: Colin Hinton
Message 6 of 22 in “fetch.c: defer fetch.followRemoteHEAD validation”
  1. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 22, 2026
  2. Junio C HamanoSep 22, 2026
  3. Colin HintonSep 23, 2026
  4. Matt HunterSep 24, 2026
  5. Colin HintonSep 25, 2026
  6. Matt HunterSep 24, 2026
  7. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 25, 2026
  8. Junio C HamanoSep 25, 2026
  9. Colin HintonSep 25, 2026
  10. Matt HunterSep 30, 2026
  11. Junio C HamanoSep 30, 2026
  12. Colin HintonOct 3, 2026
  13. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 25, 2026
  14. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 3, 2026
  15. Junio C HamanoOct 4, 2026
  16. Colin HintonOct 4, 2026
  17. Junio C HamanoOct 4, 2026
  18. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 4, 2026
  19. Matt HunterOct 5, 2026
  20. Junio C HamanoOct 5, 2026
  21. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 6, 2026
  22. Junio C HamanoOct 7, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.