Skip to content

Commit d5c2ca5

Browse files
KarthikNayakgitster
authored andcommitted
midx: pass repository to load_multi_pack_index
The `load_multi_pack_index` function in midx uses `the_repository` variable to access the `repository` struct. Modify the function and its callee's to send the `repository` field. This moves usage of `the_repository` to the `test-read-midx.c` file. While that is not optimal, it is okay, since the upcoming commits will slowly move the usage of `the_repository` up the layers and remove it eventually. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fae9bae commit d5c2ca5

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

midx.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,18 +372,19 @@ static struct multi_pack_index *load_multi_pack_index_chain(struct repository *r
372372
return m;
373373
}
374374

375-
struct multi_pack_index *load_multi_pack_index(const char *object_dir,
375+
struct multi_pack_index *load_multi_pack_index(struct repository *r,
376+
const char *object_dir,
376377
int local)
377378
{
378379
struct strbuf midx_name = STRBUF_INIT;
379380
struct multi_pack_index *m;
380381

381382
get_midx_filename(&midx_name, object_dir);
382383

383-
m = load_multi_pack_index_one(the_repository, object_dir,
384+
m = load_multi_pack_index_one(r, object_dir,
384385
midx_name.buf, local);
385386
if (!m)
386-
m = load_multi_pack_index_chain(the_repository, object_dir, local);
387+
m = load_multi_pack_index_chain(r, object_dir, local);
387388

388389
strbuf_release(&midx_name);
389390

@@ -727,7 +728,7 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
727728
if (!strcmp(object_dir, m_search->object_dir))
728729
return 1;
729730

730-
m = load_multi_pack_index(object_dir, local);
731+
m = load_multi_pack_index(r, object_dir, local);
731732

732733
if (m) {
733734
struct multi_pack_index *mp = r->objects->multi_pack_index;
@@ -881,7 +882,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
881882
struct pair_pos_vs_id *pairs = NULL;
882883
uint32_t i;
883884
struct progress *progress = NULL;
884-
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
885+
struct multi_pack_index *m = load_multi_pack_index(r, object_dir, 1);
885886
struct multi_pack_index *curr;
886887
verify_midx_error = 0;
887888

midx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ void get_midx_chain_filename(struct strbuf *buf, const char *object_dir);
9797
void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
9898
const unsigned char *hash, const char *ext);
9999

100-
struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
100+
struct multi_pack_index *load_multi_pack_index(struct repository *r,
101+
const char *object_dir,
102+
int local);
101103
int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
102104
struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
103105
uint32_t pack_int_id);

t/helper/test-read-midx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int read_midx_file(const char *object_dir, const char *checksum,
1818
struct multi_pack_index *m;
1919

2020
setup_git_directory();
21-
m = load_multi_pack_index(object_dir, 1);
21+
m = load_multi_pack_index(the_repository, object_dir, 1);
2222

2323
if (!m)
2424
return 1;
@@ -82,7 +82,7 @@ static int read_midx_checksum(const char *object_dir)
8282
struct multi_pack_index *m;
8383

8484
setup_git_directory();
85-
m = load_multi_pack_index(object_dir, 1);
85+
m = load_multi_pack_index(the_repository, object_dir, 1);
8686
if (!m)
8787
return 1;
8888
printf("%s\n", hash_to_hex(get_midx_checksum(m)));
@@ -98,7 +98,7 @@ static int read_midx_preferred_pack(const char *object_dir)
9898

9999
setup_git_directory();
100100

101-
midx = load_multi_pack_index(object_dir, 1);
101+
midx = load_multi_pack_index(the_repository, object_dir, 1);
102102
if (!midx)
103103
return 1;
104104

@@ -121,7 +121,7 @@ static int read_midx_bitmapped_packs(const char *object_dir)
121121

122122
setup_git_directory();
123123

124-
midx = load_multi_pack_index(object_dir, 1);
124+
midx = load_multi_pack_index(the_repository, object_dir, 1);
125125
if (!midx)
126126
return 1;
127127

0 commit comments

Comments
 (0)