From 7653e9af9b9ddfc465df50203c78f5c8569d8c79 Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Sun, 19 Jan 2025 12:19:28 +0100 Subject: pack-write: pass hash_algo to `write_idx_file()` The `write_idx_file()` function uses the global `the_hash_algo` variable to access the repository's hash_algo. To avoid global variable usage, pass a hash_algo from the layers above. Since `stage_tmp_packfiles()` also resides in 'pack-write.c' and calls `write_idx_file()`, update it to accept a `struct git_hash_algo` as a parameter and pass it through to the callee. Altough the layers above could have access to the hash_algo internally, simply pass in `the_hash_algo`. This avoids any compatibility issues and bubbles up global variable usage to upper layers which can be eventually resolved. Signed-off-by: Karthik Nayak Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index cb9de5ca2c..a531d75d90 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -2093,7 +2093,8 @@ int cmd_index_pack(int argc, ALLOC_ARRAY(idx_objects, nr_objects); for (i = 0; i < nr_objects; i++) idx_objects[i] = &objects[i].idx; - curr_index = write_idx_file(index_name, idx_objects, nr_objects, &opts, pack_hash); + curr_index = write_idx_file(the_hash_algo, index_name, idx_objects, + nr_objects, &opts, pack_hash); if (rev_index) curr_rev_index = write_rev_file(rev_index_name, idx_objects, nr_objects, pack_hash, -- cgit 1.2.3-korg