sha1_file: introduce has_object_file helper.
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 10 Nov 2015 02:22:19 +0000 (02:22 +0000)
committerJeff King <peff@peff.net>
Fri, 20 Nov 2015 13:02:05 +0000 (08:02 -0500)
Add has_object_file, which is a wrapper around has_sha1_file, but for
struct object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
cache.h
sha1_file.c
diff --git a/cache.h b/cache.h
index 736abc03a4b2bde987077440453e253150a584f7..614040e70060b8fe57aa37de4eadf5b0e7ab4920 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1030,6 +1030,9 @@ static inline int has_sha1_file(const unsigned char *sha1)
        return has_sha1_file_with_flags(sha1, 0);
 }
 
+/* Same as the above, except for struct object_id. */
+extern int has_object_file(const struct object_id *oid);
+
 /*
  * Return true iff an alternate object database has a loose object
  * with the specified name.  This function does not respect replace
index 3d56746a9be12e78c2b5262948bd411acf3230a2..27ce7b705e12ca0343a4a232788494e5dee518d5 100644 (file)
@@ -3216,6 +3216,11 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
        return find_pack_entry(sha1, &e);
 }
 
+int has_object_file(const struct object_id *oid)
+{
+       return has_sha1_file(oid->hash);
+}
+
 static void check_tree(const void *buf, size_t size)
 {
        struct tree_desc desc;