builtin/commit: convert to struct object_id
[gitweb.git] / builtin / show-ref.c
index a72a626b18612b229e164a47823ceac3ebd9d5dc..013d241abc09be76c318dbc25d5fb3b40ade7b3a 100644 (file)
@@ -22,6 +22,13 @@ static void show_one(const char *refname, const struct object_id *oid)
        const char *hex;
        struct object_id peeled;
 
+       if (!has_sha1_file(oid->hash))
+               die("git show-ref: bad ref %s (%s)", refname,
+                   oid_to_hex(oid));
+
+       if (quiet)
+               return;
+
        hex = find_unique_abbrev(oid->hash, abbrev);
        if (hash_only)
                printf("%s\n", hex);
@@ -62,9 +69,6 @@ static int show_ref(const char *refname, const struct object_id *oid,
                                continue;
                        if (len == reflen)
                                goto match;
-                       /* "--verify" requires an exact match */
-                       if (verify)
-                               continue;
                        if (refname[reflen - len - 1] == '/')
                                goto match;
                }
@@ -74,17 +78,6 @@ static int show_ref(const char *refname, const struct object_id *oid,
 match:
        found_match++;
 
-       /* This changes the semantics slightly that even under quiet we
-        * detect and return error if the repository is corrupt and
-        * ref points at a nonexistent object.
-        */
-       if (!has_sha1_file(oid->hash))
-               die("git show-ref: bad ref %s (%s)", refname,
-                   oid_to_hex(oid));
-
-       if (quiet)
-               return 0;
-
        show_one(refname, oid);
 
        return 0;
@@ -205,8 +198,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 
                        if ((starts_with(*pattern, "refs/") || !strcmp(*pattern, "HEAD")) &&
                            !read_ref(*pattern, oid.hash)) {
-                               if (!quiet)
-                                       show_one(*pattern, &oid);
+                               show_one(*pattern, &oid);
                        }
                        else if (!quiet)
                                die("'%s' - not a valid ref", *pattern);