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

[RFC/PATCH 0/4] update tracking refs on explicit fetch

From
Jeff King <peff@peff.net>
Date
May 11, 2013, 16:13 UTC
Message-ID
<20130511161320.GA14990@sigill.intra.peff.net>

This is a cleaned-up version of the oft-discussed[1] concept that "git pull origin master" should update "refs/remotes/origin/master".

It is a little bit of a risky change, in that anybody who deeply cares about when their tracking ref branches are updated would be impacted. But I think the general consensus is that while you can come up with a hypothetical use case, the logic is quite tortured, and you could accomplish the same thing by keeping a local branch. Most people seem to have the mental model that remote tracking branches are basically a cache for what's on the remote, updated opportunistically as appropriate.

  [1/4]: t5510: start tracking-ref tests from a known state
  [2/4]: fetch/pull doc: untangle meaning of bare <ref>
  [3/4]: refactor "ref->merge" flag
  [4/4]: fetch: opportunistically update tracking refs

The final patch is the moral equivalent of the patch I've posted before when this topic comes up (and referenced in the threads below). But that patch did not take care not to write duplicate (mergable!) entries into FETCH_HEAD, leading to great confusion from git-pull. This series deals with that, and takes care to write the exact same FETCH_HEAD we would have written before the series.

However, Jonathan raised an interesting question: what is the point of not-for-merge entries at all? We are not going to merge them, so none of the pull/merge machinery cares about them. We do not consider extra entries in FETCH_HEAD for reachability or anything like that. Is there anybody who reads them?

If we do not care about them, we can simplify this much further, and either write the duplicates as not-for-merge, or even omit not-for-merge entries entirely. However, it is possible that some third-party scripts process FETCH_HEAD, so I took the conservative route.

Note that this patch is as greedy as possible[2]; whenever we see the LHS is fetched, we update the RHS side, even if the user did:

  git fetch origin master:foobar

Some of the discussions below argue that the behavior should not kick in for such a case. I am not sure I agree (and argue against it in those discussions). I think at this point that is the only potentially contentious item.

-Peff
[1] Past discussions:
    http://thread.gmane.org/gmane.comp.version-control.git/127163/focus=127215
    http://thread.gmane.org/gmane.comp.version-control.git/192252
    http://thread.gmane.org/gmane.comp.version-control.git/203357/focus=203442
    http://article.gmane.org/gmane.comp.version-control.git/221234
Next: Jeff King
Message 1 of 12 in “update tracking refs on explicit fetch”
  1. 0/4 update tracking refs on explicit fetchJeff King, May 11, 2013
  2. 1/4 t5510: start tracking-ref tests from a known stateJeff King, May 11, 2013
  3. Eric SunshineMay 14, 2013
  4. 2/4 fetch/pull doc: untangle meaning of bare <ref>Jeff King, May 11, 2013
  5. 3/4 refactor "ref->merge" flagJeff King, May 11, 2013
  6. 4/4 fetch: opportunistically update tracking refsJeff King, May 11, 2013
  7. Thomas RastMay 12, 2013
  8. Thomas RastMay 12, 2013
  9. Jeff KingMay 16, 2013
  10. Junio C HamanoAug 6, 2013
  11. Jeff KingAug 6, 2013
  12. Junio C HamanoAug 6, 2013

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.