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

Re: [PATCH 6/7] fetch: add configuration option fetch.followRemoteHEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2026, 14:17 UTC
Message-ID
<xmqqik7nj11i.fsf@gitster.g>
In-Reply-To
<20260612055947.1499497-7-m@lfurio.us>
Matt Hunter <m@lfurio.us> writes:

I haven't been following the discussion, so I will not comment on the idea, i.e., if it makes sense to add such a new option and configuration, but if we were to add such a thing, I have some comments on the mechanics.

By the way, do not call a "configuration variable" a "configuration option". Let's keep the vocabulary forcused without using random synonyms.

Show 31 quoted lines
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 3cc7efdd83a0..a21bb82274d4 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -103,6 +103,7 @@ static struct string_list negotiation_include = STRING_LIST_INIT_NODUP;
>  
>  struct fetch_config {
>  	enum display_format display_format;
> +	enum follow_remote_head_settings follow_remote_head;
>  	int all;
>  	int prune;
>  	int prune_tags;
> @@ -173,6 +174,22 @@ static int git_fetch_config(const char *k, const char *v,
>  			    "fetch.output", v);
>  	}
>  
> +	if (!strcmp(k, "fetch.followremotehead")) {
> +		if (!v)
> +			return config_error_nonbool(k);
> +		else if (!strcasecmp(v, "never"))
> +			fetch_config->follow_remote_head = FOLLOW_REMOTE_NEVER;
> +		else if (!strcasecmp(v, "create"))
> +			fetch_config->follow_remote_head = FOLLOW_REMOTE_CREATE;
> +		else if (!strcasecmp(v, "warn"))
> +			fetch_config->follow_remote_head = FOLLOW_REMOTE_WARN;
> +		else if (!strcasecmp(v, "always"))
> +			fetch_config->follow_remote_head = FOLLOW_REMOTE_ALWAYS;
> +		else
> +			die(_("invalid value for '%s': '%s'"),
> +				"fetch.followRemoteHEAD", v);
> +	}

I think these uses of strcasecmp() are unnecessary and actively harms end-user experience. This is especially true because the value given to remote.<name>.followRemoteHEAD is case sensitive.

Instead of saying "if you want X to happen, set this variable to 'create'", you have to say "'create', or any other case variations thereof like 'CrEAte'" somehow, for very dubious gain to the end users. If you use strcmp(), and document only all lowercase forms, it would guarantee to avoid confusing a newbie who read the variable to be set to 'never' on one blog and 'Never' on another and wonder if 'NEVER' would work or not.

Admittedly values to some existing configuration variables may be parsed case insensitively but we should aim to fix the mistake in the longer term, and we should certainly not add more of them.

Is it sensible to die() here? If you are fetching from somewhere without keeping a set of remote-tracking branches for it (i.e., a single shot "git fetch https://github.com/gitster/git master"), you do not care what garbage value is in fetch.followRemoteHEAD. Perhaps the version of Git that is slightly newer than the version that ships with this patch defined new valid values that this patch does not know about, and such a user who is doing a single-shot fetch may have that setting to help them working with their usual non-single shot repositories, but they use a newer version of Git for such regular work, and they are using slightly old version of Git to perform this single-shot fetch. The point is that the configured value will *NOT* be used for such a user, and dying only because this piece of code does not understand the configuration that will not be used is of dubious value.

Previous: Matt HunterNext: Matt Hunter
Message 15 of 38 in “followRemoteHEAD management question”
  1. Matt HunterJun 5, 2026
  2. Jeff KingJun 8, 2026
  3. Matt HunterJun 11, 2026
  4. Jeff KingJun 11, 2026
  5. Bence FerdinandyJun 11, 2026
  6. Matt HunterJun 12, 2026
  7. 0/7 Introduce fetch.followRemoteHEAD config optionMatt Hunter, Jun 12, 2026
  8. 1/7 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 12, 2026
  9. 2/7 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 12, 2026
  10. 3/7 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 12, 2026
  11. 4/7 fetch: rename function report_set_headMatt Hunter, Jun 12, 2026
  12. 5/7 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 12, 2026
  13. 6/7 fetch: add configuration option fetch.followRemoteHEADMatt Hunter, Jun 12, 2026
  14. Matt HunterJun 12, 2026
  15. Junio C HamanoJun 12, 2026
  16. Matt HunterJun 13, 2026
  17. 7/7 fetch: fixup a misaligned commentMatt Hunter, Jun 12, 2026
  18. 0/7 Introduce fetch.followRemoteHEAD config variableMatt Hunter, Jun 16, 2026
  19. 1/7 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 16, 2026
  20. 2/7 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 16, 2026
  21. 3/7 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 16, 2026
  22. 4/7 fetch: rename function report_set_headMatt Hunter, Jun 16, 2026
  23. 5/7 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 16, 2026
  24. 6/7 fetch: add configuration variable fetch.followRemoteHEADMatt Hunter, Jun 16, 2026
  25. 7/7 fetch: fixup a misaligned commentMatt Hunter, Jun 16, 2026
  26. Junio C HamanoJun 16, 2026
  27. Junio C HamanoJun 17, 2026
  28. Matt HunterJun 18, 2026
  29. Junio C HamanoJun 18, 2026
  30. 0/8 Introduce fetch.followRemoteHEAD config variableMatt Hunter, Jun 19, 2026
  31. 3/8 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 19, 2026
  32. 1/8 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 19, 2026
  33. 4/8 fetch: rename function report_set_headMatt Hunter, Jun 19, 2026
  34. 5/8 fetch: return 0 on known git_fetch_configMatt Hunter, Jun 19, 2026
  35. 2/8 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 19, 2026
  36. 6/8 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 19, 2026
  37. 7/8 fetch: add configuration variable fetch.followRemoteHEADMatt Hunter, Jun 19, 2026
  38. 8/8 fetch: fixup a misaligned commentMatt Hunter, Jun 19, 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.