diff options
author | Patrick Steinhardt <ps@pks.im> | 2025-03-10 08:13:27 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-03-10 13:16:19 -0700 |
commit | f6e174b2d8b83c17376b163fc4f8062fa3140a04 (patch) | |
tree | 70027c3b1bb65e0f6002aa560449242a37d84b51 /object-file.c | |
parent | 1a6768d1dd6d92b34f25507091ff0775371e19cb (diff) |
object-file-convert: stop depending on `the_repository`
There are multiple sites in "object-file-convert.c" where we use the
global `the_repository` variable, either explicitly or implicitly by
using `the_hash_algo`. All of these callsites are transitively called
from `convert_object_file()`, which indeed has no repo as input.
Refactor the function so that it receives a repository as a parameter
and pass it through to all internal functions to get rid of the
dependency. Remove the `USE_THE_REPOSITORY_VARIABLE` define.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r-- | object-file.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/object-file.c b/object-file.c index b3e0276b2a..b0e237a2ac 100644 --- a/object-file.c +++ b/object-file.c @@ -1793,7 +1793,7 @@ static int oid_object_info_convert(struct repository *r, if (type == -1) return -1; if (type != OBJ_BLOB) { - ret = convert_object_file(&outbuf, + ret = convert_object_file(the_repository, &outbuf, the_hash_algo, input_algo, content, size, type, !do_die); free(content); @@ -2510,7 +2510,7 @@ int write_object_file_flags(const void *buf, unsigned long len, hash_object_file(compat, buf, len, type, &compat_oid); else { struct strbuf converted = STRBUF_INIT; - convert_object_file(&converted, algo, compat, + convert_object_file(the_repository, &converted, algo, compat, buf, len, type, 0); hash_object_file(compat, converted.buf, converted.len, type, &compat_oid); @@ -2550,7 +2550,8 @@ int write_object_file_literally(const void *buf, unsigned long len, &compat_oid); else if (compat_type != -1) { struct strbuf converted = STRBUF_INIT; - convert_object_file(&converted, algo, compat, + convert_object_file(the_repository, + &converted, algo, compat, buf, len, compat_type, 0); hash_object_file(compat, converted.buf, converted.len, compat_type, &compat_oid); |