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

Re: 'git clone' doesn't use alternates automatically?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2009, 00:55 UTC
Message-ID
<7vtz7f2cy6.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<885649360901311208s4bc17ae3me2062b07b302291e@mail.gmail.com>
James Pickens <jepicken@gmail.com> writes:
> So, is there any reason 'git clone' shouldn't automatically use
> the alternates that it copied into the new repository?

When you say "git clone" without -s, you are saying "I do not want to use the repository I am cloning from as my alternate, because I do not know if will stay stable. I do not trust it."

This would be a very sensible way to clone, if you were cloning my repository whose 'pu' and its constituent topic branches are subject to rewinding at any time. After I rebase some of the branches and rebuild 'pu', and prune the unnecessary objects from my repository, the objects you may have been borrowing from me will be gone from my repository. Of course, I can remove my repository altogether any time, and when that happens, your repository will have many missing objects.

That is why "-s" is not the default.

Only when you positively know that the other repository will not drop branches or rewind them, perhaps because you control that repository yourself, it is safe to use it as your alternate, and you use commands like "git clone -s" and/or "git clone --reference" to do so.

        Side note. People on k.org are encouraged to use Linus's
        repository as an alternate to save space on the k.org machine,
        because it is known that Linus's repository will never rewind its
        branches.

Now, if you are cloning from a local filesystem, by default we will copy the objects/info/alternates from the source repository to the new one. It may be debatable if this is a sensible thing to do. On one hand, because you are saying you don't trust if the objects in the source repository will stay stable by not giving "-s", it might be sensible not to trust its choice of alternates either. But in such a case, you can always use file:// URL when cloning to get a full freestanding copy.

I suspect you are trying to improve the other extreme end: trusting all the other repositories involved in the cloning process a lot more than the code currently does.

I do not think it is a bad thing to do per-se.

I haven't looked at the codepaths involved recently, but if I recall correctly, optimizing of cloning from a repository that uses alternates itself was never a part of the initial design considerations. I suspect there may be an ample room for you to optimize things.

Previous: Jeff KingNext: James Pickens
Message 11 of 13 in “'git clone' doesn't use alternates automatically?”
  1. James PickensJan 30, 2009
  2. Jeff KingJan 31, 2009
  3. James PickensJan 31, 2009
  4. Jakub NarebskiJan 31, 2009
  5. James PickensJan 31, 2009
  6. Jeff KingJan 31, 2009
  7. Junio C HamanoFeb 1, 2009
  8. Jeff KingFeb 2, 2009
  9. Junio C HamanoFeb 3, 2009
  10. Jeff KingFeb 3, 2009
  11. Junio C HamanoFeb 1, 2009
  12. James PickensFeb 1, 2009
  13. Junio C HamanoFeb 1, 2009

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.