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

Re: "git fetch" fails for a --reference clone after an outer forced push

From
Jeff King <peff@peff.net>
Date
Dec 27, 2024, 04:05 UTC
Message-ID
<20241227040551.GA86251@coredump.intra.peff.net>
In-Reply-To
<SJ0PR11MB58148000A9DCB33CCFD792A0C60D2@SJ0PR11MB5814.namprd11.prod.outlook.com>
On Thu, Dec 26, 2024 at 05:36:34PM +0000, Mirochnik, Oleg V wrote:
Show 6 quoted lines
> But one thing is still confusing and inconsistent IMO - why using
> local path for clone still works (even with the git-gc in both master
> and mirror which removes the obsoleted commit object) while it should
> not (based on your explanation and the "git help clone" snippet you
> provided)
> Could you please clarify?

When clone is given a regular path (and not a file:// url), the "--local" mode optimizations are used by default. And in that mode, all of the objects from the source repo are actually hard-linked into the cloned repo. We still set up a pointer to the --reference repository, but none of its objects will be used immediately (since we should have everything we need by hard-linking the source repo).

So here:
> git clone --reference `pwd`/mirror `pwd`/master local1

...there will be hard-links from local1 to the packs in master. So even if "mirror" gets rid of those objects, there will still be copies in local1.

I think if you were to repack local1, it would drop those duplicate objects (because it passes "-l" to "git-repack" under the hood). And then you'd still be subject to the same problems if "mirror" also gets rid of its copies.

-Peff
Previous: Mirochnik, Oleg VNext: Mirochnik, Oleg V
Message 4 of 5 in “"git fetch" fails for a --reference clone after an outer forced push”
  1. Mirochnik, Oleg VDec 25, 2024
  2. Jeff KingDec 26, 2024
  3. Mirochnik, Oleg VDec 26, 2024
  4. Jeff KingDec 27, 2024
  5. Mirochnik, Oleg VDec 27, 2024

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.