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; } /* diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 4d1c3ba664..6b6db62c4e 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -611,4 +611,9 @@ test_expect_success 'fsck notices dangling objects' ' ) ' +test_expect_success 'fsck $name notices bogus $name' ' + test_must_fail git fsck bogus && + test_must_fail git fsck $_z40 +' + test_done