Subject: Re: git fsck exit code?

From: Jeff King <[email-masked]>
Date: Fri, 29 Aug 2014 16:31:46 -0400

On Fri, Aug 29, 2014 at 04:18:00PM -0400, David Turner wrote:

> > Even if git does not die, whenever it says broken link, missing
> > object, or object corrupt, we set errors_found and that variable
> > affects the exit status of fsck.  What does "some errors" exactly
> > mean in the original report?  Dangling objects are *not* errors and
> > should not cause fsck to report an error with its exit status.
> 
> error in tree 9f50addba2b4e9e928d9c6a7056bdf71b36fba90: contains
> duplicate file entries
> 
> (at least -- there might be more, but that's the one that bit me)

I think that we just don't set "errors_found" in fsck_obj (nor do we in
fsck_obj_buffer, but in that case its caller is verify-pack, which
propagates the return code). Maybe (completely untested):

diff --git a/builtin/fsck.c b/builtin/fsck.c
index d42a27d..29de901 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -388,7 +388,8 @@ static void fsck_sha1_list(void)
 		unsigned char *sha1 = entry->sha1;
 
 		sha1_list.entry[i] = NULL;
-		fsck_sha1(sha1);
+		if (fsck_sha1(sha1))
+			errors_found |= ERROR_OBJECT;
 		free(entry);
 	}
 	sha1_list.nr = 0;