split-index: stop using the_repository and the_hash_algo

Reference the hash algorithm of the passed-in index throughout the code. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Mar 19, 2026 at 19:48 UTC 84df6e350125f22c45060ad3233691621c5de671
1 file changed +7 -6
split-index.c
+7 -6
@@ -1,4 +1,3 @@
1 -#define USE_THE_REPOSITORY_VARIABLE
1 #define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
@@ -6,6 +5,7 @@
5 #include "hash.h"
6 #include "mem-pool.h"
7 #include "read-cache-ll.h"
8 +#include "repository.h"
9 #include "split-index.h"
10 #include "strbuf.h"
11 #include "ewah/ewok.h"
@@ -25,16 +25,17 @@ struct split_index *init_split_index(struct index_state *istate)
25 int read_link_extension(struct index_state *istate,
26 const void *data_, unsigned long sz)
27 {
28 + const struct git_hash_algo *algo = istate->repo->hash_algo;
29 const unsigned char *data = data_;
30 struct split_index *si;
31 int ret;
32
32 - if (sz < the_hash_algo->rawsz)
33 + if (sz < algo->rawsz)
34 return error("corrupt link extension (too short)");
35 si = init_split_index(istate);
35 - oidread(&si->base_oid, data, the_repository->hash_algo);
36 - data += the_hash_algo->rawsz;
37 - sz -= the_hash_algo->rawsz;
36 + oidread(&si->base_oid, data, algo);
37 + data += algo->rawsz;
38 + sz -= algo->rawsz;
39 if (!sz)
40 return 0;
41 si->delete_bitmap = ewah_new();
@@ -56,7 +57,7 @@ int write_link_extension(struct strbuf *sb,
57 struct index_state *istate)
58 {
59 struct split_index *si = istate->split_index;
59 - strbuf_add(sb, si->base_oid.hash, the_hash_algo->rawsz);
60 + strbuf_add(sb, si->base_oid.hash, istate->repo->hash_algo->rawsz);
61 if (!si->delete_bitmap && !si->replace_bitmap)
62 return 0;
63 ewah_serialize_strbuf(si->delete_bitmap, sb);