diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-03-28 14:13:50 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-03-28 14:13:50 -0700 |
| commit | 1002f28a527d33893f7dab068dbac7011f84af65 (patch) | |
| tree | 9b9ada23d952e936d496597d03064c10d8d9f73d /oid-array.c | |
| parent | The eleventh batch (diff) | |
| parent | t1016-compatObjectFormat: add tests to verify the conversion between objects (diff) | |
| download | git-1002f28a527d33893f7dab068dbac7011f84af65.tar.gz git-1002f28a527d33893f7dab068dbac7011f84af65.zip | |
Merge branch 'eb/hash-transition'
Work to support a repository that work with both SHA-1 and SHA-256
hash algorithms has started.
* eb/hash-transition: (30 commits)
t1016-compatObjectFormat: add tests to verify the conversion between objects
t1006: test oid compatibility with cat-file
t1006: rename sha1 to oid
test-lib: compute the compatibility hash so tests may use it
builtin/ls-tree: let the oid determine the output algorithm
object-file: handle compat objects in check_object_signature
tree-walk: init_tree_desc take an oid to get the hash algorithm
builtin/cat-file: let the oid determine the output algorithm
rev-parse: add an --output-object-format parameter
repository: implement extensions.compatObjectFormat
object-file: update object_info_extended to reencode objects
object-file-convert: convert commits that embed signed tags
object-file-convert: convert commit objects when writing
object-file-convert: don't leak when converting tag objects
object-file-convert: convert tag objects when writing
object-file-convert: add a function to convert trees between algorithms
object: factor out parse_mode out of fast-import and tree-walk into in object.h
cache: add a function to read an OID of a specific algorithm
tag: sign both hashes
commit: export add_header_signature to support handling signatures on tags
...
Diffstat (limited to 'oid-array.c')
| -rw-r--r-- | oid-array.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/oid-array.c b/oid-array.c index 8e4717746c..1f36651754 100644 --- a/oid-array.c +++ b/oid-array.c @@ -6,12 +6,20 @@ void oid_array_append(struct oid_array *array, const struct object_id *oid) { ALLOC_GROW(array->oid, array->nr + 1, array->alloc); oidcpy(&array->oid[array->nr++], oid); + if (!oid->algo) + oid_set_algo(&array->oid[array->nr - 1], the_hash_algo); array->sorted = 0; } -static int void_hashcmp(const void *a, const void *b) +static int void_hashcmp(const void *va, const void *vb) { - return oidcmp(a, b); + const struct object_id *a = va, *b = vb; + int ret; + if (a->algo == b->algo) + ret = oidcmp(a, b); + else + ret = a->algo > b->algo ? 1 : -1; + return ret; } void oid_array_sort(struct oid_array *array) |
