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

Alternates corruption issue

From
RPRichard Purdie <richard.purdie@linuxfoundation.org>
Date
Jan 31, 2012, 14:05 UTC
Message-ID
<1328018729.13744.26.camel@ted>

I have a problem with git clone commands using alternates failing by mixing up different repositories. I have a situation where I could end up with both:

/srv/mirrors/repo /srv/mirrors/repo.git

as bare clones.
I then try cloning "repo" with alternates with the command:

$ git clone -s -n /srv/mirrors/repo /tmp/foo Cloning into /tmp/foo... done.

$ cat /tmp/foo/.git/objects/info/alternates /srv/mirrors/repo.git/objects

Note how I'm now referencing repo.git, not repo. This doesn't work as expected giving some very bizarre results when actually using the repository.

I appreciate this is a rather bizarre corner case but its one that is breaking the build system I work with. Ideally people would use a consistent URL for the same repository but we have an example where they haven't and this really shouldn't break like this.

Looking at the code, the cause seems to be
clone.c:get_repo_path():
	static char *suffix[] = { "/.git", ".git", "" };
since its looking in order for:
 repo/.git (fails)
 repo.git (suceeds, incorrect)
 repo (never looked at)

I'm not sure what would break if that order were to change, swapping the last two options.

I can "force" the issue by running:
git clone -s -n /srv/mirrors/repo/ /tmp/foo
but this results in the slightly odd looking:

$ cat /tmp/foo/.git/objects/info/alternates /srv/mirrors/repo//objects

which does at least work.
Any idea if its possible to fix the root cause of this problem?
Cheers,
Richard
Next: Jeff King
Message 1 of 19 in “Alternates corruption issue”
  1. Richard PurdieJan 31, 2012
  2. Jeff KingJan 31, 2012
  3. Junio C HamanoJan 31, 2012
  4. Jeff KingJan 31, 2012
  5. Jonathan NiederJan 31, 2012
  6. Jeff KingJan 31, 2012
  7. Jonathan NiederJan 31, 2012
  8. Jeff KingJan 31, 2012
  9. Jonathan NiederJan 31, 2012
  10. Jeff KingJan 31, 2012
  11. Jonathan NiederJan 31, 2012
  12. Jeff KingFeb 2, 2012
  13. Junio C HamanoFeb 3, 2012
  14. Jeff KingFeb 3, 2012
  15. Junio C HamanoFeb 3, 2012
  16. Jeff KingFeb 3, 2012
  17. Junio C HamanoFeb 3, 2012
  18. Jeff KingFeb 3, 2012
  19. Richard PurdieFeb 3, 2012

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.