summaryrefslogtreecommitdiff
path: root/object-file.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2021-04-26 01:02:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-27 07:31:38 (GMT)
commit5951bf467ea92458c3bea3051c8413041f3b27d5 (patch)
treee26a68adea2c27c1fdc80c93ef0aff2cd71a494d /object-file.c
parentab795f0d77aec52496557eb69a5fc9e4f60ea1fd (diff)
downloadgit-5951bf467ea92458c3bea3051c8413041f3b27d5.zip
git-5951bf467ea92458c3bea3051c8413041f3b27d5.tar.gz
git-5951bf467ea92458c3bea3051c8413041f3b27d5.tar.bz2
Use the final_oid_fn to finalize hashing of object IDs
When we're hashing a value which is going to be an object ID, we want to zero-pad that value if necessary. To do so, use the final_oid_fn instead of the final_fn anytime we're going to create an object ID to ensure we perform this operation. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/object-file.c b/object-file.c
index ef1eb98..1d8c82f 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1054,7 +1054,7 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
break;
r->hash_algo->update_fn(&c, buf, readlen);
}
- r->hash_algo->final_fn(real_oid.hash, &c);
+ r->hash_algo->final_oid_fn(&real_oid, &c);
close_istream(st);
return !oideq(oid, &real_oid) ? -1 : 0;
}
@@ -1755,7 +1755,7 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
algo->init_fn(&c);
algo->update_fn(&c, hdr, *hdrlen);
algo->update_fn(&c, buf, len);
- algo->final_fn(oid->hash, &c);
+ algo->final_oid_fn(oid, &c);
}
/*
@@ -1927,7 +1927,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
if (ret != Z_OK)
die(_("deflateEnd on object %s failed (%d)"), oid_to_hex(oid),
ret);
- the_hash_algo->final_fn(parano_oid.hash, &c);
+ the_hash_algo->final_oid_fn(&parano_oid, &c);
if (!oideq(oid, &parano_oid))
die(_("confused by unstable object source data for %s"),
oid_to_hex(oid));
@@ -2508,7 +2508,7 @@ static int check_stream_oid(git_zstream *stream,
return -1;
}
- the_hash_algo->final_fn(real_oid.hash, &c);
+ the_hash_algo->final_oid_fn(&real_oid, &c);
if (!oideq(expected_oid, &real_oid)) {
error(_("hash mismatch for %s (expected %s)"), path,
oid_to_hex(expected_oid));