submodule-config: stop using `the_hash_algo`
We have two uses of `the_hash_algo` in "submodule-config.c":
- One trivial use in `gitmodules_cb`, which we can convert to use the
hash algorithm of the repository that's already available in the
caller's context.
- One use where we compute the hashmap key of an object ID. We should
only ever get valid, populated object IDs here, and consequently we
can easily adapt that function to use the hash algorithm of the
passed-in object ID.
Adapt both sites accordingly. Safeguard us against the case where the
passed-in object ID is _not_ properly initialized. While this case
shouldn't ever happen, it doesn't hurt to be defensive.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
jch^2
parent
8d91f0a9fd
commit
f218de8a7a
|
|
@ -133,7 +133,9 @@ void submodule_cache_free(struct submodule_cache *cache)
|
|||
static unsigned int hash_oid_string(const struct object_id *oid,
|
||||
const char *string)
|
||||
{
|
||||
return memhash(oid->hash, the_hash_algo->rawsz) + strhash(string);
|
||||
if (oid->algo == GIT_HASH_UNKNOWN)
|
||||
BUG("hashing an object ID with unknown algorithm");
|
||||
return memhash(oid->hash, hash_algos[oid->algo].rawsz) + strhash(string);
|
||||
}
|
||||
|
||||
static void cache_put_path(struct submodule_cache *cache,
|
||||
|
|
@ -824,7 +826,7 @@ static int gitmodules_cb(const char *var, const char *value,
|
|||
|
||||
parameter.cache = repo->submodule_cache;
|
||||
parameter.treeish_name = NULL;
|
||||
parameter.gitmodules_oid = null_oid(the_hash_algo);
|
||||
parameter.gitmodules_oid = null_oid(repo->hash_algo);
|
||||
parameter.overwrite = 1;
|
||||
|
||||
return parse_config(var, value, ctx, ¶meter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue