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

Re: [BUG?] fetch into shallow sends a large number of objects

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2016, 23:47 UTC
Message-ID
<xmqqio0xn93q.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160307221539.GA24034@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 21 quoted lines
> I don't know how the client invoked git, but we can guess what happened
> and simulate with:
>
>   git tag shallow ecd7ea6033fe8a05d5c21f3a54355fded6942659
>   git tag old 067f265bb512c95b22b83ccd121b9facbddcf6b1
>   git tag new d7a6d9295d718c6015be496880f1a293bdd89185
>
>   git clone --no-local --bare --branch=shallow --depth=1 . clone.git
>   cd clone.git
>   git fetch origin old:refs/tags/old
>   git fetch origin new:refs/tags/new
>
> Of the two follow-up fetches in the clone, the first is reasonably fast
> (it just grabs a few new commits on top of the shallow base), but the
> second is expensive (it grabs the merge which pulls in the whole
> history). If we add "--depth=1" to each of those fetches, everything
> remains fast.
>
> Is this user error to call "git fetch" without "--depth" in the
> subsequent cases? Or should git remember that we are in a shallow repo,
> and presume that the user by default wants to keep things shallow?

Hmph, you shouldn't, and I somehow thought that you do not, have to explicitly say things like "--deepen" to break the original shallowness, but your example illustrates that the logic to do so is not well thought out. A new side branch will prevent you from hitting an already-known shallow cut-off and traverse down to the root.

Giving a random "depth" in subsequent fetch would however not work very well, I suspect, as that is very prone to make the part of the history the user originally obtained, and presumably used to build her own history, into an island that is unconnected to the updated tip of the history.

I also do not offhand think of a good way to use the topology or timestamp to figure out the best "depth" to truncate the side branch at. The server side may be able to figure out that things before 'F' in your picture is not relevant for a client that has the shallow cut-off at 067f265, but the side branch can be forked arbitrarily long in the past, or it may not even share the ancient part of the history and has its own root commit.

Previous: Jeff KingNext: Duy Nguyen
Message 2 of 16 in “[BUG?] fetch into shallow sends a large number of objects”
  1. Jeff KingMar 7, 2016
  2. Junio C HamanoMar 7, 2016
  3. Duy NguyenMar 8, 2016
  4. Jeff KingMar 8, 2016
  5. Jeff KingMar 8, 2016
  6. Duy NguyenMar 8, 2016
  7. Jeff KingMar 8, 2016
  8. Jeff KingMar 8, 2016
  9. Duy NguyenMar 8, 2016
  10. Duy NguyenMar 10, 2016
  11. Jeff KingMar 10, 2016
  12. Junio C HamanoMar 10, 2016
  13. Jeff KingMar 10, 2016
  14. Duy NguyenMar 11, 2016
  15. Junio C HamanoMar 11, 2016
  16. Jeff KingMar 11, 2016

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.