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

Re: git-svn and huge data and modifying the git-svn-HEAD branch directly

From
Junio C Hamano <junkio@cox.net>
Date
Mar 1, 2006, 19:11 UTC
Message-ID
<7virqyf094.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0603010935201.22647@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> But if somebody does the get_sha1() magic, and Junio agrees, then I think 
> it would be a great thing to do.
I am inclined to agree here.
Some caveats upfront, though.

Since I was bitten at least once by attempting get_sha1() to deal with ambiguous names (the issue was between heads and tags but I think there are similar issues here) I am really reluctant to have the function look at anywhere other than heads/ and tags/ without explicit prefix.

Currently get_sha1_basic() says:
	* look in $GIT_DIR with these prefixes in turn and take
          the first match: "", "refs", "refs/tags", "refs/heads".
The extended one _would_ in addition say one of these things:
	* if none of the above prefixes work, try other
          directories under refs/ as prefixes and take the first
          match.
	or
	* if none of the above prefixes work, try other
          directories under refs/ as prefixes and if there is a
          unique match take it.  If there are more than one
          match, do not take either.

In the context of get_sha1(), get_sha1_basic() is used like this:

	* if get_sha1_basic() finds an answer, use it.
          Otherwise see if it is an abbreviated object name.

The behaviour of a naive implementation of the former would depend on readdir() and traversal order, which makes (from the end user's point of view) a hard to understand confusion that is not reproducible. Another repository cloned from such would even give you different answers.

The latter at first sounds sane, but it has a subtle issue, which was what bitten me previously between heads/ and tags/. In that broken version, if you have a head called "dead" and a tag with the same name, neither was taken ("they are not unique, so do not take either!") and we ended up finding an object whose SHA1 name began with those two bytes 0xDE 0xAD. I do not think this has happened in the field, fortunately, but it would have been quite hard to diagnose.

So if we were to do it, I would say do the latter, but be very careful to make sure you fail the whole get_sha1() when you bail out of the "try possible prefixes" codepath because of ambiguity. There may be other issues involved, but I wouldn't know -- I reverted the "do not take either if they are ambiguous between heads/ and tags/" patch primarily because of the reason from the above paragraph, but also did not want to deal with any other potential issues to keep my sanity ;-).

Previous: Linus TorvaldsNext: Josef Weidendorfer
Message 20 of 33 in “git-svn and huge data and modifying the git-svn-HEAD branch directly”
  1. Nicolas Vilz 'niv'Feb 27, 2006
  2. Eric WongFeb 27, 2006
  3. Jan HarkesFeb 27, 2006
  4. Eric WongFeb 27, 2006
  5. Martin LanghoffFeb 28, 2006
  6. Linus TorvaldsFeb 28, 2006
  7. Martin LanghoffFeb 28, 2006
  8. Eric WongMar 1, 2006
  9. Andreas EricssonMar 1, 2006
  10. Linus TorvaldsMar 1, 2006
  11. Andreas EricssonMar 1, 2006
  12. Linus TorvaldsMar 1, 2006
  13. Josef WeidendorferMar 1, 2006
  14. Shawn PearceMar 1, 2006
  15. Linus TorvaldsMar 1, 2006
  16. Josef WeidendorferMar 1, 2006
  17. Linus TorvaldsMar 1, 2006
  18. Josef WeidendorferMar 1, 2006
  19. Linus TorvaldsMar 1, 2006
  20. Junio C HamanoMar 1, 2006
  21. Josef WeidendorferMar 1, 2006
  22. Martin LanghoffMar 1, 2006
  23. Carl WorthMar 1, 2006
  24. Linus TorvaldsMar 1, 2006
  25. Johannes SchindelinMar 1, 2006
  26. Petr BaudisMar 19, 2006
  27. Linus TorvaldsMar 19, 2006
  28. Junio C HamanoMar 19, 2006
  29. contrib/git-svn: tell the user to not modify git-svn-HEAD directlyEric Wong, Feb 27, 2006
  30. Nicolas Vilz 'niv'Feb 27, 2006
  31. Eric WongFeb 27, 2006
  32. Nicolas Vilz 'niv'Feb 27, 2006
  33. contrib/git-svn: correct commit example in manpageEric Wong, Feb 27, 2006

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.