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

Re: git-svnimport failed and now git-repack hates me

From
Junio C Hamano <junkio@cox.net>
Date
Jan 4, 2007, 06:25 UTC
Message-ID
<7v1wmbnw9x.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0701031737300.4989@woody.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 7 quoted lines
> On Wed, 3 Jan 2007, Chris Lee wrote:
>>
>> So I'm using git 1.4.1, and I have been experimenting with importing
>> the KDE sources from Subversion using git-svnimport.
>
> As one single _huge_ import? All the sub-projects together? I have to say, 
> that sounds pretty horrid.

Thanks -- you said everything I should have said on this issue while I was in bed ;-).

> Junio - I suspect "pack-check.c" really shouldn't try to do it as one 
> single humungous "SHA1_Update()" call. It showed one bug on PPC, I 
> wouldn't be surprised if it's implicated now on some other architecture. 

If Chris still has that huge .pack & .idx pair, it would be a very good guinea pig to try a few things on, assuming that this problem is that the pack-check.c feeds a huge blob to SHA-1 function with a single call.

 (1) Apply the attached patch on top of "master" (the patch
     should apply to 1.4.1 almost cleanly as well, except that
     we have hashcmp(a,b) instead of memcmp(a,b,20) since then),
     and see what it says about the packfile.  If your suspicion
     is correct, it should complain about your SHA-1
     implementation.
 (2) Try tip of "next" to see if its verify-pack passes the
     check.  Again, if your suspicion is correct, it should, since it
     uses Shawn's sliding mmap() stuff that will not feed the
     whole pack in one go.
 (3) I suspect that the tip of "master" should work except
     verify-pack.  It may be interesting to see how well the tip
     of "master" and "next" performs on the resulting huge pack
     (say, "time git log -p HEAD >/dev/null").  I am hoping this
     would be another datapoint to judge the runtime penalty of
     Shawn's sliding mmap() in "next" -- I suspect the penalty
     is either negligible or even negative.
diff --git a/pack-check.c b/pack-check.c
index c0caaee..738a0c5 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -29,6 +29,28 @@ static int verify_packfile(struct packed_git *p)
 	pack_base = p->pack_base;
 	SHA1_Update(&ctx, pack_base, pack_size - 20);
 	SHA1_Final(sha1, &ctx);
+
+	if (1) {
+		SHA_CTX another;
+		unsigned char *data = p->pack_base;
+		unsigned long size = pack_size - 20;
+		const unsigned long batchsize = (1u << 20);
+		unsigned char another_sha1[20];
+
+		SHA1_Init(&another);
+		while (size) {
+			unsigned long batch = size;
+			if (batchsize < batch)
+				batch = batchsize;
+			SHA1_Update(&another, data, batch);
+			size -= batch;
+			data += batch;
+		}
+		SHA1_Final(another_sha1, &another);
+		if (hashcmp(sha1, another_sha1))
+			die("Your SHA-1 implementation cannot hash %lu bytes correctly at once", pack_size - 20);
+	}
+
 	if (hashcmp(sha1, (unsigned char *)pack_base + pack_size - 20))
 		return error("Packfile %s SHA1 mismatch with itself",
 			     p->pack_name);
Previous: Eric WongNext: Junio C Hamano
Message 20 of 55 in “git-svnimport failed and now git-repack hates me”
  1. Chris LeeJan 3, 2007
  2. Linus TorvaldsJan 4, 2007
  3. Shawn O. PearceJan 4, 2007
  4. Shawn O. PearceJan 4, 2007
  5. Chris LeeJan 4, 2007
  6. Shawn O. PearceJan 4, 2007
  7. Chris LeeJan 4, 2007
  8. Shawn O. PearceJan 4, 2007
  9. Chris LeeJan 4, 2007
  10. Shawn O. PearceJan 4, 2007
  11. Chris LeeJan 4, 2007
  12. Chris LeeJan 4, 2007
  13. Chris LeeJan 4, 2007
  14. Linus TorvaldsJan 4, 2007
  15. Chris LeeJan 4, 2007
  16. Eric WongJan 4, 2007
  17. Randal L. SchwartzJan 4, 2007
  18. Eric WongJan 4, 2007
  19. git-svn: make --repack work consistently between fetch and multi-fetchEric Wong, Jan 5, 2007
  20. Junio C HamanoJan 4, 2007
  21. pack-check.c::verify_packfile(): don't run SHA-1 update on huge dataJunio C Hamano, Jan 4, 2007
  22. Chris LeeJan 4, 2007
  23. Junio C HamanoJan 4, 2007
  24. Chris LeeJan 5, 2007
  25. Junio C HamanoJan 5, 2007
  26. Chris LeeJan 5, 2007
  27. Shawn O. PearceJan 5, 2007
  28. Chris LeeJan 5, 2007
  29. Junio C HamanoJan 5, 2007
  30. Linus TorvaldsJan 5, 2007
  31. alanJan 5, 2007
  32. Eric WongJan 7, 2007
  33. Linus TorvaldsJan 5, 2007
  34. Junio C HamanoJan 5, 2007
  35. Linus TorvaldsJan 5, 2007
  36. Linus TorvaldsJan 5, 2007
  37. Junio C HamanoJan 5, 2007
  38. Linus TorvaldsJan 5, 2007
  39. Johannes SchindelinJan 6, 2007
  40. Chris LeeJan 5, 2007
  41. Junio C HamanoJan 5, 2007
  42. Linus TorvaldsJan 5, 2007
  43. Junio C HamanoJan 5, 2007
  44. Linus TorvaldsJan 6, 2007
  45. Linus TorvaldsJan 6, 2007
  46. Junio C HamanoJan 6, 2007
  47. Linus TorvaldsJan 6, 2007
  48. Chris LeeJan 4, 2007
  49. Linus TorvaldsJan 4, 2007
  50. Sasha KhapyorskyJan 4, 2007
  51. Chris LeeJan 4, 2007
  52. git-svnimport: support for incremental importSasha Khapyorsky, Jan 7, 2007
  53. Chris LeeJan 7, 2007
  54. Sasha KhapyorskyJan 7, 2007
  55. git-svnimport: fix edge revisions double importingSasha Khapyorsky, Jan 8, 2007

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.