diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2023-10-01 21:40:07 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-10-02 14:57:38 -0700 |
commit | 52fca06db28a23fcea159431c1c9dafca26d609c (patch) | |
tree | bdb3341d6f511c7b85836272cf6a8b3a193ace77 /object-name.h | |
parent | d50cbe4a5d989c454c620cbaa0c64a06a4a2f9a2 (diff) |
object-names: support input of oids in any supported hash
Support short oids encoded in any algorithm, while ensuring enough of
the oid is specified to disambiguate between all of the oids in the
repository encoded in any algorithm.
By default have the code continue to only accept oids specified in the
storage hash algorithm of the repository, but when something is
ambiguous display all of the possible oids from any accepted oid
encoding.
A new flag is added GET_OID_HASH_ANY that when supplied causes the
code to accept oids specified in any hash algorithm, and to return the
oids that were resolved.
This implements the functionality that allows both SHA-1 and SHA-256
object names, from the "Object names on the command line" section of
the hash function transition document.
Care is taken in get_short_oid so that when the result is ambiguous
the output remains the same if GIT_OID_HASH_ANY was not supplied. If
GET_OID_HASH_ANY was supplied objects of any hash algorithm that match
the prefix are displayed.
This required updating repo_for_each_abbrev to give it a parameter so
that it knows to look at all hash algorithms.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-name.h')
-rw-r--r-- | object-name.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/object-name.h b/object-name.h index 9ae5223071..064ddc97d1 100644 --- a/object-name.h +++ b/object-name.h @@ -67,7 +67,8 @@ enum get_oid_result get_oid_with_context(struct repository *repo, const char *st typedef int each_abbrev_fn(const struct object_id *oid, void *); -int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *); +int repo_for_each_abbrev(struct repository *r, const char *prefix, + const struct git_hash_algo *algo, each_abbrev_fn, void *); int set_disambiguate_hint_config(const char *var, const char *value); |