X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=sha1_file.c;h=b2074e7a8ee6d55fdb1094b93a2954bd164d5445;hb=7f3ed824a4ec15fc9725a4992b399ea4364c5adb;hp=1b551e4609dfde6f047de54c4ee7ed4b006c0ce5;hpb=08bda2085cc095863888bb4bb7a73960a9a379fd;p=git.git diff --git a/sha1_file.c b/sha1_file.c index 1b551e460..b2074e7a8 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2517,3 +2517,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)); +}