From: Simon 'corecode' Schubert Date: Thu, 22 Feb 2007 16:46:15 GMT Subject: Re: [PATCH] Add git-bundle: move objects and references by archive Message-ID: <45DDC8D7.60902@fs.ei.tum.de> In-Reply-To: Johannes Schindelin wrote: > Hi, > > On Thu, 22 Feb 2007, Simon 'corecode' Schubert wrote: > >> Johannes Schindelin wrote: >>> Hi, >>> >>> On Wed, 21 Feb 2007, Nicolas Pitre wrote: >>> >>>> On Thu, 22 Feb 2007, Johannes Schindelin wrote: >>>> >>>>> diff --git a/index-pack.c b/index-pack.c >>>>> index fa9a0e7..5ccf4c4 100644 >>>>> --- a/index-pack.c >>>>> +++ b/index-pack.c >>>>> @@ -457,8 +457,8 @@ static void parse_pack_objects(unsigned char *sha1) >>>>> /* 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 && S_ISREG(st.st_mode) && st.st_size != consumed_bytes) >>>>> + die("pack has junk at the end: 0%o, %d, %d %d", st.st_mode, >>>>> (int)st.st_size, (int)consumed_bytes, input_fd); >>>>> if (!nr_deltas) >>>>> return; >>>> What is this supposed to mean? >>> The funny thing is, if you stream part of the bundle file to index-pack, >>> S_ISREG(st.st_mode) is true, even if input_fd == 0. >> Well, of course: you opened a regular file and pass this as stdin to >> index-pack. >> >> Maybe something like this would be cleaner: >> >> if (IS_REF(st.st_mode) && lseek(input_fd, 0, SEEK_CUR) != st.st_size) >> die("..."); > > The lseek would fail whenever the input is _not_ a file, dying. Since > index-pack is called from fetch-pack, with a socket instead of a file, it > would fail for the most common user. that's why i put IS_REF (should read IS_REG) there. but as nicolas pointed out, this won't work for read-ahead. cheers simon -- Serve - BSD +++ RENT this banner advert +++ ASCII Ribbon /"\ Work - Mac +++ space for low €€€ NOW!1 +++ Campaign \ / Party Enjoy Relax | http://dragonflybsd.org Against HTML \ Dude 2c 2 the max ! http://golden-apple.biz Mail + News / \