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

Re: [PATCH v2 0/7] Introduce fetch.followRemoteHEAD config variable

From
Matt Hunter <m@lfurio.us>
Date
Jun 18, 2026, 04:21 UTC
Message-ID
<DJBVYP58YNTU.LQ7VXFIQE84H@lfurio.us>
In-Reply-To
<xmqqcxxp1j2t.fsf@gitster.g>
On Wed Jun 17, 2026 at 7:51 AM EDT, Junio C Hamano wrote:
Show 14 quoted lines
>>
>> 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?".

This explanation makes much more sense to me than what you said in your response to the first iteration. I believe I understand your vision better here.

Show 10 quoted lines
>>
>> 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), ...

Right. It seems like the design of the config callback mechanism doesn't work well for the dynamic behavior described in your ideal case.

I've tried to test out a few ideas to make it work, and each one so far ends up feeling hacky very quickly.

Show 9 quoted lines
>
> Having said all that, I do not think it is a blocker for this series
> that it does not take us into the more ideal direction and still
> makes a syntax check on a value that will not be used and complains
> to the user.  We may want an in-code NEEDSWORK comment to hint
> future developers that they may want to revamp both of the code
> paths for fetch.followRemoteHEAD and remote.*.followremotehead not
> to complain when the values are unneeded and die when the unrecognized
> value is needed to continue, though.

Personally, even in the case where we can disregard any and all followRemoteHEAD settings on a one-shot fetch, I don't think die()-ing on an unrecognized value should be the course of action.

As you pointed out in your last response to this topic, a future git release may implement additional choices for followRemoteHEAD. If a user opts in to this new functionality, but finds themself using an older version of git (for whatever reason), I would still expect the fetch operation to continue, just using different semantics for followRemoteHEAD.

In fact, the better behavior might be to fall to "never" if the user asks to do something we don't understand. In this case, we just emit the warning, continue with fetch, but followRemoteHEAD does nothing - not even create a missing ref.

>
> Other than that, this looks excellent.  Thanks.
Thanks for the great feedback and consideration!

If you like, I can apply the appropriate NEEDSWORK comment, possibly add a warning to 'fetch.followRemoteHEAD' parsing (matching the 'remote' side), and we can call this good to go for now.

Previous: Junio C HamanoNext: Junio C Hamano
Message 28 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.