summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2020-01-30 20:32:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-31 18:45:39 (GMT)
commit2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2 (patch)
tree9039d3dd520e915bf531c8f2f32190a4a87d9ccd /cache-tree.c
parent7ad5c44d9ce559703245d389aa71c4445dc9359c (diff)
downloadgit-2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2.zip
git-2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2.tar.gz
git-2dcde20e1c55fc2e3f9e9e6d48e93c39ec5661d2.tar.bz2
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 'cache-tree.c')
-rw-r--r--cache-tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 8c51a15..a537a80 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -407,13 +407,15 @@ static int update_one(struct cache_tree *it,
if (repair) {
struct object_id oid;
- hash_object_file(buffer.buf, buffer.len, tree_type, &oid);
+ hash_object_file(the_hash_algo, buffer.buf, buffer.len,
+ tree_type, &oid);
if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
oidcpy(&it->oid, &oid);
else
to_invalidate = 1;
} else if (dryrun) {
- hash_object_file(buffer.buf, buffer.len, tree_type, &it->oid);
+ hash_object_file(the_hash_algo, buffer.buf, buffer.len,
+ tree_type, &it->oid);
} else if (write_object_file(buffer.buf, buffer.len, tree_type,
&it->oid)) {
strbuf_release(&buffer);
@@ -828,7 +830,8 @@ static void verify_one(struct repository *r,
strbuf_addf(&tree_buf, "%o %.*s%c", mode, entlen, name, '\0');
strbuf_add(&tree_buf, oid->hash, r->hash_algo->rawsz);
}
- hash_object_file(tree_buf.buf, tree_buf.len, tree_type, &new_oid);
+ hash_object_file(r->hash_algo, tree_buf.buf, tree_buf.len, tree_type,
+ &new_oid);
if (!oideq(&new_oid, &it->oid))
BUG("cache-tree for path %.*s does not match. "
"Expected %s got %s", len, path->buf,