git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] incorrect error message in "git fsck" for empty loose objects
@ 2012-01-23 10:19 Matthieu Moy
  2012-02-06 16:24 ` [PATCH] fsck: give accurate error message on empty loose object files Matthieu Moy
  0 siblings, 1 reply; 2+ messages in thread
From: Matthieu Moy @ 2012-01-23 10:19 UTC (permalink / raw)
  To: git; +Cc: Junio C. Hamano

Hi,

If a loose object is empty, "git fsck" reports it as corrupt (which is
good), but with the following error message:

$ git fsck
Checking object directories: 100% (256/256), done.
fatal: failed to read object c1738f6288c9e5d5e58da00ced34d284ae93976c: Invalid argument
$ cat .git/objects/c1/738f6288c9e5d5e58da00ced34d284ae93976c 
$ ls -l .git/objects/c1/738f6288c9e5d5e58da00ced34d284ae93976c
-r--r--r-- 1 moy synchron 0 Jan 20 16:20 .git/objects/c1/738f6288c9e5d5e58da00ced34d284ae93976c

"Invalid argument" is really not the error message one would expect.
Before that, git used to say:

   fatal: loose object c1738f6288c9e5d5e58da00ced34d284ae93976c (stored in
   .git/objects/c1/738f6288c9e5d5e58da00ced34d28
   4ae93976c) is corrupt

Which was far better.

This bisects back to 3ba7a065527a (A loose object is not corrupt if it
cannot be read due to EMFILE), which essentially boils down to:

--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2090,16 +2090,21 @@ void *read_sha1_file_repl(const unsigned char *sha1,
                          const unsigned char **replacement)
[...]
+       errno = 0;
+       data = read_object(repl, type, size);
        if (data) {
                if (replacement)
                        *replacement = repl;
                return data;
        }
 
+       if (errno != ENOENT)
+               die_errno("failed to read object %s", sha1_to_hex(sha1));
+

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-06 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-23 10:19 [BUG] incorrect error message in "git fsck" for empty loose objects Matthieu Moy
2012-02-06 16:24 ` [PATCH] fsck: give accurate error message on empty loose object files Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).