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

Re: auto-packing on kernel.org? please?

From
Linus Torvalds <torvalds@osdl.org>
Date
Nov 21, 2005, 20:38 UTC
Message-ID
<Pine.LNX.4.64.0511211211130.13959@g5.osdl.org>
In-Reply-To
<7v3blprcwk.fsf@assigned-by-dhcp.cox.net>
On Mon, 21 Nov 2005, Junio C Hamano wrote:
> 
> One cop-out: do fsck-objects upfront before making a pack.  This
> would populate your buffer cache so it might not be a bad thing.

Well, it's extremely expensive most of the time. It's often as expensive as the packing itself. So I don't like that option very much.

Show 6 quoted lines
> Alternatively:
> 
>         name=$( {
>                 git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) ||
>                 echo Gaaahhh
>         } | git-pack-objects --non-empty $pack_objects .tmp-pack)

Actually, some dim memories prodded me to some man-page digging, and the "pipefail" option in particular.

It seems to be a common option to both ksh and bash, so
	set -o pipefail

seems like it should fix this. Sadly, I think it's pretty recent in bash (ksh apparently got it in -93, bash seems to have gotten it only as of version 3.0, which is definitely recent enough that we can't just assume it).

[ Also, bash seems to have a variable called $PIPESTATUS, but that's 
  bash-specific (I don't know when it was enabled). ]
Anyway, doing a
	set -o pipefail

should never be the wrong thing to do, but the problem is figuring out whether the option is available or not, since if it isn't available, it's considered an error ;/

So with all that, how about we take your "Gaah" idea, and simplify it: just pipe stderr too. That, together with making git-pack-objects tell what garbage it got, actually does the rigth thing:

	[torvalds@g5 git-clone]$ git repack -a -d
	fatal: expected sha1, got garbage:
	 error: Could not read 7f59dbbb8f8d479c1d31453eac06ec765436a780
with this pretty simple patch.
Whaddaya think?
			Linus
---
diff --git a/git-repack.sh b/git-repack.sh
index 4e16d34..c0f271d 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -41,7 +41,7 @@ esac
 if [ "$local" ]; then
 	pack_objects="$pack_objects --local"
 fi
-name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
+name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) 2>&1 |
 	git-pack-objects --non-empty $pack_objects .tmp-pack) ||
 	exit 1
 if [ -z "$name" ]; then
diff --git a/pack-objects.c b/pack-objects.c
index 4e941e7..8864a31 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -524,7 +524,7 @@ int main(int argc, char **argv)
 		unsigned char sha1[20];
 
 		if (get_sha1_hex(line, sha1))
-			die("expected sha1, got garbage");
+			die("expected sha1, got garbage:\n %s", line);
 		hash = 0;
 		p = line+40;
 		while (*p) {
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 33 in “auto-packing on kernel.org? please?”
  1. Linus TorvaldsOct 13, 2005
  2. Carl BaldwinNov 21, 2005
  3. Linus TorvaldsNov 21, 2005
  4. Junio C HamanoNov 21, 2005
  5. Linus TorvaldsNov 21, 2005
  6. Junio C HamanoNov 21, 2005
  7. Chuck LeverNov 22, 2005
  8. Linus TorvaldsNov 22, 2005
  9. Catalin MarinasNov 22, 2005
  10. Linus TorvaldsNov 22, 2005
  11. Chuck LeverNov 22, 2005
  12. Catalin MarinasNov 23, 2005
  13. Carl BaldwinNov 22, 2005
  14. Linus TorvaldsNov 22, 2005
  15. Linus TorvaldsOct 13, 2005
  16. Dirk BehmeOct 16, 2005
  17. Daniel BarkalowOct 16, 2005
  18. Nick HengeveldOct 16, 2005
  19. Brian GerstOct 16, 2005
  20. Junio C HamanoOct 16, 2005
  21. Nick HengeveldOct 16, 2005
  22. Junio C HamanoOct 16, 2005
  23. Nick HengeveldOct 17, 2005
  24. Junio C HamanoOct 17, 2005
  25. Nick HengeveldOct 17, 2005
  26. Junio C HamanoOct 17, 2005
  27. Daniel BarkalowOct 17, 2005
  28. Linus TorvaldsOct 17, 2005
  29. Nick HengeveldOct 17, 2005
  30. Daniel BarkalowOct 17, 2005
  31. Johannes SchindelinOct 16, 2005
  32. Brian GerstOct 16, 2005
  33. Catalin MarinasNov 23, 2005

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.