[PATCH] Don't call fstat() on stdin in index-pack.
- From
Bart Trojanowski <bart@jukie.net>
- Date
- Jan 19, 2007, 02:44 UTC
- Message-ID
- <20070119024436.GQ8624@jukie.net>
- In-Reply-To
- <20070118212615.GO8624@jukie.net>
* Bart Trojanowski <bart@jukie.net> [070118 16:26]:
Show 13 quoted lines
> $ git push origin > updating 'refs/heads/my-ocf+fsm_v2.6.18' > from 0000000000000000000000000000000000000000 > to 380541e91358d7a5e2fe37c81c520c92a3094951 > Generating pack... > Done counting 727 objects. > Result has 708 objects. > Deltifying 708 objects. > 100% (708/708) done > Writing 708 objects. > 100% (708/708) done > Total 708 (delta 535), reused 275 (delta 218) > fatal: cannot fstat packfile: Value too large for defined data type
I had a look at the code in index-pack.c and noticed that this error is printed input_fd is set to 0 in open_pack_file().
| if (fstat(input_fd, &st))
| die("cannot fstat packfile: %s", strerror(errno));
| if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes)
| die("pack has junk at the end");It seems strange to me to call fstat on fd 0 to get st_size info.
Granted, st_mode should tell us that it's not a regular file, but already know it's not a regular file.
So I removed it. And now it works (I verified that the git-diff output on both sides matches).
-Bart
----
>From fcd359655e12a4b6424f989b7c01cbbb8a551287 Mon Sep 17 00:00:00 2001
From: Bart Trojanowski <bart@jukie.net> Date: Fri, 19 Jan 2007 02:39:27 +0000 Subject: [PATCH] Don't call fstat() on stdin in index-pack.
This fixes a issues with a large git-push with a 32bit git on a 64bit kernel.
Signed-off-by: Bart Trojanowski <bart@jukie.net> --- index-pack.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/index-pack.c b/index-pack.c index 72e0962..e7870a9 100644 --- a/index-pack.c +++ b/index-pack.c @@ -455,10 +455,12 @@ static void parse_pack_objects(unsigned char *sha1) use(20); /* If input_fd is a file, we should have reached its end now. */ - if (fstat(input_fd, &st)) - die("cannot fstat packfile: %s", strerror(errno)); - if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes) - die("pack has junk at the end"); + if (input_fd) { + if (fstat(input_fd, &st)) + die("cannot fstat packfile: %s", strerror(errno)); + if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes) + die("pack has junk at the end"); + } if (!nr_deltas) return;
-- 1.5.0.rc1.gdf1b-dirty