aboutsummaryrefslogtreecommitdiff
path: root/pack.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2025-01-19 12:19:29 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-21 12:36:34 -0800
commit6b2aa7fd371c93df44cebff072bef193104f43f8 (patch)
tree45157097b4219f3697865c7b266f567c33c7d91c /pack.h
parent7653e9af9b9ddfc465df50203c78f5c8569d8c79 (diff)
downloadgit-6b2aa7fd371c93df44cebff072bef193104f43f8.tar.xz
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 <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack.h')
-rw-r--r--pack.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/pack.h b/pack.h
index c650fdbe2d..8a84ea475c 100644
--- a/pack.h
+++ b/pack.h
@@ -105,8 +105,18 @@ struct ref;
void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought);
-char *write_rev_file(const char *rev_name, struct pack_idx_entry **objects, uint32_t nr_objects, const unsigned char *hash, unsigned flags);
-char *write_rev_file_order(const char *rev_name, uint32_t *pack_order, uint32_t nr_objects, const unsigned char *hash, unsigned flags);
+char *write_rev_file(const struct git_hash_algo *hash_algo,
+ const char *rev_name,
+ struct pack_idx_entry **objects,
+ uint32_t nr_objects,
+ const unsigned char *hash,
+ unsigned flags);
+char *write_rev_file_order(const struct git_hash_algo *hash_algo,
+ const char *rev_name,
+ uint32_t *pack_order,
+ uint32_t nr_objects,
+ const unsigned char *hash,
+ unsigned flags);
/*
* The "hdr" output buffer should be at least this big, which will handle sizes