Merge branch 'sb/describe-blob' into next
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Feb 2018 21:34:32 +0000 (13:34 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Feb 2018 21:34:32 +0000 (13:34 -0800)
"git describe $garbage" stopped giving any errors when the garbage
happens to be a string with 40 hexadecimal letters.

* sb/describe-blob:
describe: confirm that blobs actually exist

builtin/describe.c
t/t6120-describe.sh
index c4289847063ac02ed061f890ffd71cd329d67109..e4869df7b434845544dfcc0c37cae6a77cd42dad 100644 (file)
@@ -502,7 +502,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);
index a5d901502414f25616a474152ee0f5816465bd37..bae78c4e89e2402d5ab37e3b7cd094dde41d69b3 100755 (executable)
@@ -378,4 +378,12 @@ check_describe tags/A --all A
 check_describe tags/c --all c
 check_describe heads/branch_A --all --match='branch_*' branch_A
 
+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