diff mbox series

[v3,8/8] midx: inline the `MIDX_MIN_SIZE` definition

Message ID 20241127-374-refactor-midx-c-and-midx-write-c-to-not-depend-on-global-state-v3-8-c5a99f85009b@gmail.com (mailing list archive)
State New
Headers show
Series Change midx.c and midx-write.c to not use global variables | expand

Commit Message

Karthik Nayak Nov. 27, 2024, 4:28 p.m. UTC
The `MIDX_MIN_SIZE` definition is used to check the midx_size in
`local_multi_pack_index_one`. This definition relies on the
`the_hash_algo` global variable. Inline this and remove the global
variable usage.

With this, remove `USE_THE_REPOSITORY_VARIABLE` usage from `midx.c`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 midx.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/midx.c b/midx.c
index f45ea842cd6eda23d2eadc9deaae43839aef24c1..e0eae1c25ec91f7db5670ff9bacdf0e195c35795 100644
--- a/midx.c
+++ b/midx.c
@@ -1,5 +1,3 @@ 
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "git-compat-util.h"
 #include "config.h"
 #include "dir.h"
@@ -94,8 +92,6 @@  static int midx_read_object_offsets(const unsigned char *chunk_start,
 	return 0;
 }
 
-#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + the_hash_algo->rawsz)
-
 static struct multi_pack_index *load_multi_pack_index_one(struct repository *r,
 							  const char *object_dir,
 							  const char *midx_name,
@@ -122,7 +118,7 @@  static struct multi_pack_index *load_multi_pack_index_one(struct repository *r,
 
 	midx_size = xsize_t(st.st_size);
 
-	if (midx_size < MIDX_MIN_SIZE) {
+	if (midx_size < (MIDX_HEADER_SIZE + r->hash_algo->rawsz)) {
 		error(_("multi-pack-index file %s is too small"), midx_name);
 		goto cleanup_fail;
 	}