aboutsummaryrefslogtreecommitdiffstats
path: root/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'hash.h')
-rw-r--r--hash.h28
1 files changed, 12 insertions, 16 deletions
diff --git a/hash.h b/hash.h
index 756166ce5e..ad2c919991 100644
--- a/hash.h
+++ b/hash.h
@@ -282,21 +282,6 @@ struct git_hash_algo {
/* The hash finalization function for object IDs. */
git_hash_final_oid_fn final_oid_fn;
- /* The non-cryptographic hash initialization function. */
- git_hash_init_fn unsafe_init_fn;
-
- /* The non-cryptographic hash context cloning function. */
- git_hash_clone_fn unsafe_clone_fn;
-
- /* The non-cryptographic hash update function. */
- git_hash_update_fn unsafe_update_fn;
-
- /* The non-cryptographic hash finalization function. */
- git_hash_final_fn unsafe_final_fn;
-
- /* The non-cryptographic hash finalization function. */
- git_hash_final_oid_fn unsafe_final_oid_fn;
-
/* The OID of the empty tree. */
const struct object_id *empty_tree;
@@ -305,6 +290,9 @@ struct git_hash_algo {
/* The all-zeros OID. */
const struct object_id *null_oid;
+
+ /* The unsafe variant of this hash function, if one exists. */
+ const struct git_hash_algo *unsafe;
};
extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
@@ -320,9 +308,17 @@ int hash_algo_by_length(int len);
/* 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;
+ size_t i;
+ for (i = 0; i < GIT_HASH_NALGOS; i++) {
+ const struct git_hash_algo *algop = &hash_algos[i];
+ if (p == algop)
+ return i;
+ }
+ return GIT_HASH_UNKNOWN;
}
+const struct git_hash_algo *unsafe_hash_algo(const struct git_hash_algo *algop);
+
const struct object_id *null_oid(void);
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)