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

Re: [RFC/PATCH] Add fetch.updateHead option

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2020, 15:53 UTC
Message-ID
<xmqqwnyi3bml.fsf@gitster.c.googlers.com>
In-Reply-To
<87wnyjdnb3.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 32 quoted lines
> On Wed, Nov 18 2020, Felipe Contreras wrote:
>
>> Users might change the behavior when running "git fetch" so that the
>> remote's HEAD symbolic ref is updated at certain point.
>>
>> For example after running "git remote add" the remote HEAD is not
>> set like it is with "git clone".
>>
>> Setting "fetch.updatehead = missing" would probably be a sensible
>> default that everyone would want, but for now the default behavior is to
>> never update HEAD, so there shouldn't be any functional changes.
>>
>> For the next major version of Git, we might want to change this default.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>>
>> This is just a RFC, the tests are missing.
>
> I haven't taken much time to re-think through the patch/implications of
> this, but I remember running into this and going through some pre-patch
> investigation at some point.
>
> It's really annoying in some cases that "clone" isn't creating the same
> state as "remote". IIRC I was doing some heuristics to figure out the
> remote branch name etc.
>
> Isn't this something we can just change without an option? There were a
> bunch of cases in clone/fetch that were different for no different
> reasons, IIRC I patched one or two of those in the past. But I haven't
> gone through the history of the feature and checked if it was
> intentional.

I think what Peff outlined earlier was reasonable. "remote add -f", since it talks with the remote, should be able to learn where their HEAD points at and set it up. "remote add" that does not talk to the remote cannot do so and "fetch" could help but we should not touch existing refs/remotes/$name/HEAD by default [*1*], as the symref is meant to indicate the local choice of which one of their branches is significant to _us_ and what "clone" does is merely to give it the initial value.

But when interacting with a remote whose choice of HEAD is always what the local user wants to follow, letting "git fetch" update refs/remotes/$name/HEAD to a newly observed value would be a welcome optional feature.

I haven't thought through what Jonathan (Nieder) said about an option to fail a fetch when refs/remotes/$name/HEAD and the remote HEAD "git fetch" observed do not match. It may make sense in some cases but not always, and I do not know what the right explanation for the use case the mode is supposed to be a good match is.

[Footnote]

*1* This is important when you work in more than one repositories with working tree and use fetch+rebase to keep them in sync.

Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 13 in “Add fetch.updateHead option”
  1. Add fetch.updateHead optionFelipe Contreras, Nov 18, 2020
  2. Ævar Arnfjörð BjarmasonNov 18, 2020
  3. Felipe ContrerasNov 18, 2020
  4. Junio C HamanoNov 18, 2020
  5. Felipe ContrerasNov 18, 2020
  6. Jeff KingNov 20, 2020
  7. Junio C HamanoNov 21, 2020
  8. Jeff KingNov 21, 2020
  9. Felipe ContrerasNov 21, 2020
  10. Jeff KingNov 24, 2020
  11. Felipe ContrerasNov 21, 2020
  12. Felipe ContrerasNov 21, 2020
  13. Jeff KingNov 24, 2020

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.