git svn: avoid uninitialized var in 'reset'
[gitweb.git] / sha1_file.c
index ff65328006404fd0d113f2cd4c4d52377b4cc8cf..28c056e074d1a89e4a3d266eff49c899bfd35e59 100644 (file)
@@ -2516,3 +2516,13 @@ int read_pack_header(int fd, struct pack_header *header)
                return PH_ERROR_PROTOCOL;
        return 0;
 }
+
+void assert_sha1_type(const unsigned char *sha1, enum object_type expect)
+{
+       enum object_type type = sha1_object_info(sha1, NULL);
+       if (type < 0)
+               die("%s is not a valid object", sha1_to_hex(sha1));
+       if (type != expect)
+               die("%s is not a valid '%s' object", sha1_to_hex(sha1),
+                   typename(expect));
+}