From: Junio C Hamano Date: Tue, 20 Mar 2007 06:05:56 GMT Subject: Re: git 1.5.1-rc1 doesn't like empty files Message-ID: <7v1wjkbgaj.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <7v648wbgiy.fsf@assigned-by-dhcp.cox.net> Junio C Hamano writes: > Linus Torvalds writes: > >> We've had this bug before - thinking that we don't need to inflate() >> anything because we already had it all.. >> >> Linus > > Thanks. I think we _do_ need a big fat warning near the code to > avoid the same mistake in the future... By the way, I think the test that comes after the part you fixed is wrong (I know it is my bad without running git-blame). Since we are making sure that we eat everything, we should expect Z_STREAM_END and no avail_in. diff --git a/sha1_file.c b/sha1_file.c index d7dc80d..7dc16ea 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1037,7 +1037,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size status = inflate(stream, Z_FINISH); } buf[size] = 0; - if ((status == Z_OK || status == Z_STREAM_END) && !stream->avail_in) { + if (status == Z_STREAM_END && !stream->avail_in) { inflateEnd(stream); return buf; }