]> git.ipfire.org Git - thirdparty/git.git/blobdiff - hash.h
hex: introduce functions to print arbitrary hashes
[thirdparty/git.git] / hash.h
diff --git a/hash.h b/hash.h
index 7c8238bc2ebfded778351b58c16a3854617082c6..80881eea47b8401a780a7f3d4975f226237796f7 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -98,4 +98,17 @@ struct git_hash_algo {
 };
 extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
 
+/*
+ * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if
+ * the name doesn't match a known algorithm.
+ */
+int hash_algo_by_name(const char *name);
+/* Identical, except based on the format ID. */
+int hash_algo_by_id(uint32_t format_id);
+/* Identical, except for a pointer to struct git_hash_algo. */
+static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
+{
+       return p - hash_algos;
+}
+
 #endif