{"thread":{"id":"65306","subject":"[PATCH] split-index: stop using the_repository and the_hash_algo","startedAt":"2026-03-19T18:48:15Z","lastAt":"2026-03-19T19:01:15Z","messageCount":2,"participants":["René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"539416","messageId":"944c2331-4dec-4c98-9059-f41dc204ed86@web.de","threadId":"65306","inReplyTo":null,"subject":"[PATCH] split-index: stop using the_repository and the_hash_algo","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-03-19T18:48:07Z","receivedAt":"2026-03-19T18:48:15Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Reference the hash algorithm of the passed-in index throughout the code.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\nLow-hanging fruit..\n\n split-index.c | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/split-index.c b/split-index.c\nindex 4c74c4adda..6ba210738c 100644\n--- a/split-index.c\n+++ b/split-index.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -6,6 +5,7 @@\n #include \"hash.h\"\n #include \"mem-pool.h\"\n #include \"read-cache-ll.h\"\n+#include \"repository.h\"\n #include \"split-index.h\"\n #include \"strbuf.h\"\n #include \"ewah/ewok.h\"\n@@ -25,16 +25,17 @@ struct split_index *init_split_index(struct index_state *istate)\n int read_link_extension(struct index_state *istate,\n \t\t\t const void *data_, unsigned long sz)\n {\n+\tconst struct git_hash_algo *algo = istate->repo->hash_algo;\n \tconst unsigned char *data = data_;\n \tstruct split_index *si;\n \tint ret;\n \n-\tif (sz < the_hash_algo->rawsz)\n+\tif (sz < algo->rawsz)\n \t\treturn error(\"corrupt link extension (too short)\");\n \tsi = init_split_index(istate);\n-\toidread(&si->base_oid, data, the_repository->hash_algo);\n-\tdata += the_hash_algo->rawsz;\n-\tsz -= the_hash_algo->rawsz;\n+\toidread(&si->base_oid, data, algo);\n+\tdata += algo->rawsz;\n+\tsz -= algo->rawsz;\n \tif (!sz)\n \t\treturn 0;\n \tsi->delete_bitmap = ewah_new();\n@@ -56,7 +57,7 @@ int write_link_extension(struct strbuf *sb,\n \t\t\t struct index_state *istate)\n {\n \tstruct split_index *si = istate->split_index;\n-\tstrbuf_add(sb, si->base_oid.hash, the_hash_algo->rawsz);\n+\tstrbuf_add(sb, si->base_oid.hash, istate->repo->hash_algo->rawsz);\n \tif (!si->delete_bitmap && !si->replace_bitmap)\n \t\treturn 0;\n \tewah_serialize_strbuf(si->delete_bitmap, sb);\n-- \n2.53.0\n"},{"id":"539418","messageId":"xmqqqzpfk5ja.fsf@gitster.g","threadId":"65306","inReplyTo":"944c2331-4dec-4c98-9059-f41dc204ed86@web.de","subject":"Re: [PATCH] split-index: stop using the_repository and the_hash_algo","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-19T19:01:13Z","receivedAt":"2026-03-19T19:01:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Reference the hash algorithm of the passed-in index throughout the code.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n> Low-hanging fruit..\n\nIndeed.\n\n>\n>  split-index.c | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n>\n> diff --git a/split-index.c b/split-index.c\n> index 4c74c4adda..6ba210738c 100644\n> --- a/split-index.c\n> +++ b/split-index.c\n> @@ -1,4 +1,3 @@\n> -#define USE_THE_REPOSITORY_VARIABLE\n>  #define DISABLE_SIGN_COMPARE_WARNINGS\n>  \n>  #include \"git-compat-util.h\"\n> @@ -6,6 +5,7 @@\n>  #include \"hash.h\"\n>  #include \"mem-pool.h\"\n>  #include \"read-cache-ll.h\"\n> +#include \"repository.h\"\n>  #include \"split-index.h\"\n>  #include \"strbuf.h\"\n>  #include \"ewah/ewok.h\"\n> @@ -25,16 +25,17 @@ struct split_index *init_split_index(struct index_state *istate)\n>  int read_link_extension(struct index_state *istate,\n>  \t\t\t const void *data_, unsigned long sz)\n>  {\n> +\tconst struct git_hash_algo *algo = istate->repo->hash_algo;\n>  \tconst unsigned char *data = data_;\n>  \tstruct split_index *si;\n>  \tint ret;\n>  \n> -\tif (sz < the_hash_algo->rawsz)\n> +\tif (sz < algo->rawsz)\n>  \t\treturn error(\"corrupt link extension (too short)\");\n>  \tsi = init_split_index(istate);\n> -\toidread(&si->base_oid, data, the_repository->hash_algo);\n> -\tdata += the_hash_algo->rawsz;\n> -\tsz -= the_hash_algo->rawsz;\n> +\toidread(&si->base_oid, data, algo);\n> +\tdata += algo->rawsz;\n> +\tsz -= algo->rawsz;\n>  \tif (!sz)\n>  \t\treturn 0;\n>  \tsi->delete_bitmap = ewah_new();\n> @@ -56,7 +57,7 @@ int write_link_extension(struct strbuf *sb,\n>  \t\t\t struct index_state *istate)\n>  {\n>  \tstruct split_index *si = istate->split_index;\n> -\tstrbuf_add(sb, si->base_oid.hash, the_hash_algo->rawsz);\n> +\tstrbuf_add(sb, si->base_oid.hash, istate->repo->hash_algo->rawsz);\n>  \tif (!si->delete_bitmap && !si->replace_bitmap)\n>  \t\treturn 0;\n>  \tewah_serialize_strbuf(si->delete_bitmap, sb);\n"}]}