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, 05:29 UTC
Message-ID
<7vslc0bhz7.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1174361424.3143.42.camel@dv>
Pavel Roskin <proski@gnu.org> writes:
Show 13 quoted lines
> Hello!
>
> I don't know where this problem appeared, but it present in the current
> git (1.5.1-rc1).  Empty files become invalid objects in the repository:
>
> $ touch file 
> $ git-init
> Initialized empty Git repository in .git/
> $ git-add file
> $ git-commit -m "first commit"
> Created initial commit 16a476808d3cb0a4758997ba58193a9dcfad0fd8
> error: garbage at end of loose object
> 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'

If the error message above is linewrapped by e-mail, I think it is coming from here:

    static void *unpack_sha1_rest(z_stream *stream, void *buffer,...
    {
    ...
            if (bytes < size) {
                    stream->next_out = buf + bytes;
                    stream->avail_out = size - bytes;
                    while (status == Z_OK)
                            status = inflate(stream, Z_FINISH);
            }
            buf[size] = 0;
            if ((status == Z_OK || status == Z_STREAM_END) && !stream->avail_in) {
                    inflateEnd(stream);
                    return buf;
            }
            if (status < 0)
                    error("corrupt loose object '%s'", sha1_to_hex(sha1));
            else if (stream->avail_in)
                    error("garbage at end of loose object '%s'",
                          sha1_to_hex(sha1));
            free(buf);
            return NULL;
    }
Can you check what the value of the status is at that point?
Previous: Linus TorvaldsNext: Pavel Roskin
Message 13 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.