Code

Merge branch 'maint-1.5.4' into maint
[git.git] / builtin-show-ref.c
index ae0edddac1ad63b849dc341c8dd6519181c1e18e..a323633e296cef1797ab1d218cea83c891bc3b8d 100644 (file)
@@ -1,3 +1,4 @@
+#include "builtin.h"
 #include "cache.h"
 #include "refs.h"
 #include "object.h"
@@ -85,6 +86,9 @@ match:
                            sha1_to_hex(sha1));
                if (obj->type == OBJ_TAG) {
                        obj = deref_tag(obj, refname, 0);
+                       if (!obj)
+                               die("git-show-ref: bad tag at ref %s (%s)", refname,
+                                   sha1_to_hex(sha1));
                        hex = find_unique_abbrev(obj->sha1, abbrev);
                        printf("%s %s^{}\n", hex, refname);
                }
@@ -221,9 +225,11 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
        }
 
        if (verify) {
-               unsigned char sha1[20];
-
+               if (!pattern)
+                       die("--verify requires a reference");
                while (*pattern) {
+                       unsigned char sha1[20];
+
                        if (!prefixcmp(*pattern, "refs/") &&
                            resolve_ref(*pattern, sha1, 1, NULL)) {
                                if (!quiet)