Skip to content

Commit

Permalink
midx: inline the MIDX_MIN_SIZE definition
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
KarthikNayak authored and gitster committed Nov 28, 2024
1 parent e9b91ea commit 36a7b11
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions midx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "config.h"
#include "dir.h"
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down

0 comments on commit 36a7b11

Please sign in to comment.