From 6b2aa7fd371c93df44cebff072bef193104f43f8 Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Sun, 19 Jan 2025 12:19:29 +0100 Subject: pack-write: pass hash_algo to `write_rev_file()` The `write_rev_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. Also modify children functions `write_rev_file_order()` and `write_rev_header()` to accept 'the_hash_algo'. 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. However, in `midx-write.c`, since all usage of global variables is removed, don't reintroduce them and instead use the `repo` available in the context. Signed-off-by: Karthik Nayak Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index a531d75d90..367e02d782 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -2096,9 +2096,9 @@ int cmd_index_pack(int argc, 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, - opts.flags); + curr_rev_index = write_rev_file(the_hash_algo, rev_index_name, + idx_objects, nr_objects, + pack_hash, opts.flags); free(idx_objects); if (!verify) -- cgit v1.2.3