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

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

From
Jeff King <peff@peff.net>
Date
Jan 31, 2009, 21:55 UTC
Message-ID
<20090131215514.GB9415@coredump.intra.peff.net>
In-Reply-To
<885649360901311208s4bc17ae3me2062b07b302291e@mail.gmail.com>
On Sat, Jan 31, 2009 at 01:08:16PM -0700, James Pickens wrote:
> Well, the clone gets the alternates either way.  It just doesn't
> use them to avoid copying the data unless I give -s.  More

The other key change is that you don't depend on the origin in your alternates when you don't use "-s".

> So, is there any reason 'git clone' shouldn't automatically use
> the alternates that it copied into the new repository?  I might
> look into writing a patch if nobody objects.

I think the reason "-s" isn't the default is that alternates are fragile (as Jakub mentioned), and we don't want ot set them up without the user asking to do so.

So from what you've posted (but I haven't double checked or looked at the code), it sounds like the current behavior is:

  - with "-s", add the origin as an alternate, and use alternates while
    cloning
  - "with --reference", add some other repo as an alternate, and use
    alternates while cloning
  - without either, copy alternates from origin, but _don't_ use
    alternates while cloning

The last one seems a little silly. Why bother setting up the alternates if you're not going to use them? I guess because we might not be able to get the objects at all, otherwise, and we need to know where to copy them from. But either:

  - that is an implementation-specific detail of clone, and those
    alternates should go away after we clone
      or
  - we should fully respect those alternates

The only downside to the latter is that now somebody who has cloned a repository with alternates now has an alternates-based repository and might not know it (i.e., they might have been the one who set up alternates in the origin).

-Peff
Previous: James PickensNext: Junio C Hamano
Message 6 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.