aboutsummaryrefslogtreecommitdiffstats
path: root/apply.c
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2020-01-30 17:32:22 -0300
committerJunio C Hamano <gitster@pobox.com>2020-01-31 10:45:39 -0800
commit2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2 (patch)
tree9039d3dd520e915bf531c8f2f32190a4a87d9ccd /apply.c
parent7ad5c44d9ce559703245d389aa71c4445dc9359c (diff)
downloadgit-2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2.tar.gz
sha1-file: pass git_hash_algo to hash_object_file()
Allow hash_object_file() to work on arbitrary repos by introducing a git_hash_algo parameter. Change callers which have a struct repository pointer in their scope to pass on the git_hash_algo from the said repo. For all other callers, pass on the_hash_algo, which was already being used internally at hash_object_file(). This functionality will be used in the following patch to make check_object_signature() be able to work on arbitrary repos (which, in turn, will be used to fix an inconsistency at object.c:parse_object()). Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/apply.c b/apply.c
index fab44322c5..bdc008fae2 100644
--- a/apply.c
+++ b/apply.c
@@ -3157,7 +3157,8 @@ static int apply_binary(struct apply_state *state,
* See if the old one matches what the patch
* applies to.
*/
- hash_object_file(img->buf, img->len, blob_type, &oid);
+ hash_object_file(the_hash_algo, img->buf, img->len, blob_type,
+ &oid);
if (strcmp(oid_to_hex(&oid), patch->old_oid_prefix))
return error(_("the patch applies to '%s' (%s), "
"which does not match the "
@@ -3202,7 +3203,8 @@ static int apply_binary(struct apply_state *state,
name);
/* verify that the result matches */
- hash_object_file(img->buf, img->len, blob_type, &oid);
+ hash_object_file(the_hash_algo, img->buf, img->len, blob_type,
+ &oid);
if (strcmp(oid_to_hex(&oid), patch->new_oid_prefix))
return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),
name, patch->new_oid_prefix, oid_to_hex(&oid));