X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sha1_file.c;h=e42ef96d457f6aa12ab7d0057acf936db0335d40;hb=452c6d506b1a6dcf24d4ceaa592afc39c1c1a60e;hp=72de38909ef6b05f0aa709b78fd803c632a02044;hpb=12575b78fbc6db9eb8de12c8146c7d27eb821e09;p=git.git diff --git a/sha1_file.c b/sha1_file.c index 72de38909..e42ef96d4 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2525,3 +2525,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)); +}