]> git.ipfire.org Git - thirdparty/git.git/commit
object-names: support input of oids in any supported hash
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 2 Oct 2023 02:40:07 +0000 (21:40 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Oct 2023 21:57:38 +0000 (14:57 -0700)
commit52fca06db28a23fcea159431c1c9dafca26d609c
treebdb3341d6f511c7b85836272cf6a8b3a193ace77
parentd50cbe4a5d989c454c620cbaa0c64a06a4a2f9a2
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>
builtin/rev-parse.c
hash-ll.h
object-name.c
object-name.h