Add corner case tests for diff-index and diff-files
[gitweb.git] / builtin-show-ref.c
index 9463ff0e69b15fc0e544259e64960bc942a98368..a323633e296cef1797ab1d218cea83c891bc3b8d 100644 (file)
@@ -1,3 +1,4 @@
+#include "builtin.h"
 #include "cache.h"
 #include "refs.h"
 #include "object.h"
@@ -85,6 +86,9 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
                            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);
                }