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

Re: git 1.5.1-rc1 doesn't like empty files

From
Junio C Hamano <junkio@cox.net>
Date
Mar 20, 2007, 06:05 UTC
Message-ID
<7v1wjkbgaj.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v648wbgiy.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 9 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> 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;
 	}
Previous: Junio C HamanoNext: Linus Torvalds
Message 17 of 18 in “git 1.5.1-rc1 doesn't like empty files”
  1. Pavel RoskinMar 20, 2007
  2. Nicolas VilzMar 20, 2007
  3. Linus TorvaldsMar 20, 2007
  4. Pavel RoskinMar 20, 2007
  5. Linus TorvaldsMar 20, 2007
  6. Pavel RoskinMar 20, 2007
  7. Shawn O. PearceMar 20, 2007
  8. Alexander LitvinovMar 20, 2007
  9. Andy ParkinsMar 20, 2007
  10. Junio C HamanoMar 20, 2007
  11. Andy ParkinsMar 20, 2007
  12. Linus TorvaldsMar 20, 2007
  13. Junio C HamanoMar 20, 2007
  14. Pavel RoskinMar 20, 2007
  15. Linus TorvaldsMar 20, 2007
  16. Junio C HamanoMar 20, 2007
  17. Junio C HamanoMar 20, 2007
  18. Linus TorvaldsMar 20, 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.