From c6c7b16d23a4cb6af26acee865c2ade1a3822bef Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 16 Jan 2017 16:33:29 -0500 Subject: fsck: tighten error-checks of "git fsck " Instead of checking reachability from the refs, you can ask fsck to check from a particular set of heads. However, the error checking here is quite lax. In particular: 1. It claims lookup_object() will report an error, which is not true. It only does a hash lookup, and the user has no clue that their argument was skipped. 2. When either the name or sha1 cannot be resolved, we continue to exit with a successful error code, even though we didn't check what the user asked us to. This patch fixes both of these cases. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/fsck.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'builtin/fsck.c') diff --git a/builtin/fsck.c b/builtin/fsck.c index 75e836e2fd..bacc899a32 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -755,9 +755,11 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) if (!get_sha1(arg, sha1)) { struct object *obj = lookup_object(sha1); - /* Error is printed by lookup_object(). */ - if (!obj) + if (!obj) { + error("%s: object missing", sha1_to_hex(sha1)); + errors_found |= ERROR_OBJECT; continue; + } obj->used = 1; if (name_objects) @@ -768,6 +770,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) continue; } error("invalid parameter: expected sha1, got '%s'", arg); + errors_found |= ERROR_OBJECT; } /* -- cgit 1.2.3-korg