* [PATCH] split-index: stop using the_repository and the_hash_algo
@ 2026-03-19 18:48 René Scharfe
2026-03-19 19:01 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2026-03-19 18:48 UTC (permalink / raw)
To: Git List
Reference the hash algorithm of the passed-in index throughout the code.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
Low-hanging fruit..
split-index.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/split-index.c b/split-index.c
index 4c74c4adda..6ba210738c 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -6,6 +5,7 @@
#include "hash.h"
#include "mem-pool.h"
#include "read-cache-ll.h"
+#include "repository.h"
#include "split-index.h"
#include "strbuf.h"
#include "ewah/ewok.h"
@@ -25,16 +25,17 @@ struct split_index *init_split_index(struct index_state *istate)
int read_link_extension(struct index_state *istate,
const void *data_, unsigned long sz)
{
+ const struct git_hash_algo *algo = istate->repo->hash_algo;
const unsigned char *data = data_;
struct split_index *si;
int ret;
- if (sz < the_hash_algo->rawsz)
+ if (sz < algo->rawsz)
return error("corrupt link extension (too short)");
si = init_split_index(istate);
- oidread(&si->base_oid, data, the_repository->hash_algo);
- data += the_hash_algo->rawsz;
- sz -= the_hash_algo->rawsz;
+ oidread(&si->base_oid, data, algo);
+ data += algo->rawsz;
+ sz -= algo->rawsz;
if (!sz)
return 0;
si->delete_bitmap = ewah_new();
@@ -56,7 +57,7 @@ int write_link_extension(struct strbuf *sb,
struct index_state *istate)
{
struct split_index *si = istate->split_index;
- strbuf_add(sb, si->base_oid.hash, the_hash_algo->rawsz);
+ strbuf_add(sb, si->base_oid.hash, istate->repo->hash_algo->rawsz);
if (!si->delete_bitmap && !si->replace_bitmap)
return 0;
ewah_serialize_strbuf(si->delete_bitmap, sb);
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] split-index: stop using the_repository and the_hash_algo
2026-03-19 18:48 [PATCH] split-index: stop using the_repository and the_hash_algo René Scharfe
@ 2026-03-19 19:01 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2026-03-19 19:01 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List
René Scharfe <l.s.r@web.de> writes:
> Reference the hash algorithm of the passed-in index throughout the code.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> Low-hanging fruit..
Indeed.
>
> split-index.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/split-index.c b/split-index.c
> index 4c74c4adda..6ba210738c 100644
> --- a/split-index.c
> +++ b/split-index.c
> @@ -1,4 +1,3 @@
> -#define USE_THE_REPOSITORY_VARIABLE
> #define DISABLE_SIGN_COMPARE_WARNINGS
>
> #include "git-compat-util.h"
> @@ -6,6 +5,7 @@
> #include "hash.h"
> #include "mem-pool.h"
> #include "read-cache-ll.h"
> +#include "repository.h"
> #include "split-index.h"
> #include "strbuf.h"
> #include "ewah/ewok.h"
> @@ -25,16 +25,17 @@ struct split_index *init_split_index(struct index_state *istate)
> int read_link_extension(struct index_state *istate,
> const void *data_, unsigned long sz)
> {
> + const struct git_hash_algo *algo = istate->repo->hash_algo;
> const unsigned char *data = data_;
> struct split_index *si;
> int ret;
>
> - if (sz < the_hash_algo->rawsz)
> + if (sz < algo->rawsz)
> return error("corrupt link extension (too short)");
> si = init_split_index(istate);
> - oidread(&si->base_oid, data, the_repository->hash_algo);
> - data += the_hash_algo->rawsz;
> - sz -= the_hash_algo->rawsz;
> + oidread(&si->base_oid, data, algo);
> + data += algo->rawsz;
> + sz -= algo->rawsz;
> if (!sz)
> return 0;
> si->delete_bitmap = ewah_new();
> @@ -56,7 +57,7 @@ int write_link_extension(struct strbuf *sb,
> struct index_state *istate)
> {
> struct split_index *si = istate->split_index;
> - strbuf_add(sb, si->base_oid.hash, the_hash_algo->rawsz);
> + strbuf_add(sb, si->base_oid.hash, istate->repo->hash_algo->rawsz);
> if (!si->delete_bitmap && !si->replace_bitmap)
> return 0;
> ewah_serialize_strbuf(si->delete_bitmap, sb);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-19 19:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 18:48 [PATCH] split-index: stop using the_repository and the_hash_algo René Scharfe
2026-03-19 19:01 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox