diff --git a/builtin/describe.c b/builtin/describe.c index 5b4bfaba3f..1e7ba09693 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -498,7 +498,7 @@ static void describe(const char *arg, int last_one) if (cmit) describe_commit(&oid, &sb); - else if (lookup_blob(&oid)) + else if (sha1_object_info(oid.hash, NULL) == OBJ_BLOB) describe_blob(oid, &sb); else die(_("%s is neither a commit nor blob"), arg); diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 3e3fb462a0..50029ff6a8 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -374,4 +374,12 @@ test_expect_success ULIMIT_STACK_SIZE 'describe works in a deep repo' ' test_cmp expect actual ' +test_expect_success 'describe complains about tree object' ' + test_must_fail git describe HEAD^{tree} +' + +test_expect_success 'describe complains about missing object' ' + test_must_fail git describe $_z40 +' + test_done