Skip to content

Commit 7c14112

Browse files
pcloudsgitster
authored andcommitted
pack-*.c: remove the_repository references
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94e1082 commit 7c14112

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3481,7 +3481,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
34813481
}
34823482
}
34833483

3484-
prepare_packing_data(&to_pack);
3484+
prepare_packing_data(the_repository, &to_pack);
34853485

34863486
if (progress)
34873487
progress_state = start_progress(_("Enumerating objects"), 0);

pack-bitmap-write.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void bitmap_writer_build_type_index(struct packing_data *to_pack,
7777
break;
7878

7979
default:
80-
real_type = oid_object_info(the_repository,
80+
real_type = oid_object_info(to_pack->repo,
8181
&entry->idx.oid, NULL);
8282
break;
8383
}
@@ -262,7 +262,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
262262
if (writer.show_progress)
263263
writer.progress = start_progress("Building bitmaps", writer.selected_nr);
264264

265-
repo_init_revisions(the_repository, &revs, NULL);
265+
repo_init_revisions(to_pack->repo, &revs, NULL);
266266
revs.tag_objects = 1;
267267
revs.tree_objects = 1;
268268
revs.blob_objects = 1;
@@ -363,7 +363,7 @@ static int date_compare(const void *_a, const void *_b)
363363
void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
364364
{
365365
struct bitmap_index *bitmap_git;
366-
if (!(bitmap_git = prepare_bitmap_git()))
366+
if (!(bitmap_git = prepare_bitmap_git(to_pack->repo)))
367367
return;
368368

369369
writer.reused = kh_init_sha1();

pack-bitmap.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,27 @@ static int load_pack_bitmap(struct bitmap_index *bitmap_git)
328328
return -1;
329329
}
330330

331-
static int open_pack_bitmap(struct bitmap_index *bitmap_git)
331+
static int open_pack_bitmap(struct repository *r,
332+
struct bitmap_index *bitmap_git)
332333
{
333334
struct packed_git *p;
334335
int ret = -1;
335336

336337
assert(!bitmap_git->map);
337338

338-
for (p = get_all_packs(the_repository); p; p = p->next) {
339+
for (p = get_all_packs(r); p; p = p->next) {
339340
if (open_pack_bitmap_1(bitmap_git, p) == 0)
340341
ret = 0;
341342
}
342343

343344
return ret;
344345
}
345346

346-
struct bitmap_index *prepare_bitmap_git(void)
347+
struct bitmap_index *prepare_bitmap_git(struct repository *r)
347348
{
348349
struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
349350

350-
if (!open_pack_bitmap(bitmap_git) && !load_pack_bitmap(bitmap_git))
351+
if (!open_pack_bitmap(r, bitmap_git) && !load_pack_bitmap(bitmap_git))
351352
return bitmap_git;
352353

353354
free_bitmap_index(bitmap_git);
@@ -690,7 +691,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
690691
struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
691692
/* try to open a bitmapped pack, but don't parse it yet
692693
* because we may not need to use it */
693-
if (open_pack_bitmap(bitmap_git) < 0)
694+
if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
694695
goto cleanup;
695696

696697
for (i = 0; i < revs->pending.nr; ++i) {
@@ -955,7 +956,7 @@ void test_bitmap_walk(struct rev_info *revs)
955956
struct bitmap_test_data tdata;
956957
struct bitmap_index *bitmap_git;
957958

958-
if (!(bitmap_git = prepare_bitmap_git()))
959+
if (!(bitmap_git = prepare_bitmap_git(revs->repo)))
959960
die("failed to load bitmap indexes");
960961

961962
if (revs->pending.nr != 1)

pack-bitmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "pack-objects.h"
77

88
struct commit;
9+
struct repository;
910
struct rev_info;
1011

1112
struct bitmap_disk_header {
@@ -39,7 +40,7 @@ typedef int (*show_reachable_fn)(
3940

4041
struct bitmap_index;
4142

42-
struct bitmap_index *prepare_bitmap_git(void);
43+
struct bitmap_index *prepare_bitmap_git(struct repository *r);
4344
void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
4445
uint32_t *trees, uint32_t *blobs, uint32_t *tags);
4546
void traverse_bitmap_commit_list(struct bitmap_index *,

pack-objects.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)
9999
* (i.e. in_pack_idx also zero) should return NULL.
100100
*/
101101
mapping[cnt++] = NULL;
102-
for (p = get_all_packs(the_repository); p; p = p->next, cnt++) {
102+
for (p = get_all_packs(pdata->repo); p; p = p->next, cnt++) {
103103
if (cnt == nr) {
104104
free(mapping);
105105
return;
@@ -133,8 +133,10 @@ void oe_map_new_pack(struct packing_data *pack,
133133
}
134134

135135
/* assume pdata is already zero'd by caller */
136-
void prepare_packing_data(struct packing_data *pdata)
136+
void prepare_packing_data(struct repository *r, struct packing_data *pdata)
137137
{
138+
pdata->repo = r;
139+
138140
if (git_env_bool("GIT_TEST_FULL_IN_PACK_ARRAY", 0)) {
139141
/*
140142
* do not initialize in_pack_by_idx[] to force the

pack-objects.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "thread-utils.h"
66
#include "pack.h"
77

8+
struct repository;
9+
810
#define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
911

1012
#define OE_DFS_STATE_BITS 2
@@ -127,6 +129,7 @@ struct object_entry {
127129
};
128130

129131
struct packing_data {
132+
struct repository *repo;
130133
struct object_entry *objects;
131134
uint32_t nr_objects, nr_alloc;
132135

@@ -165,7 +168,7 @@ struct packing_data {
165168
unsigned char *layer;
166169
};
167170

168-
void prepare_packing_data(struct packing_data *pdata);
171+
void prepare_packing_data(struct repository *r, struct packing_data *pdata);
169172

170173
static inline void packing_data_lock(struct packing_data *pdata)
171174
{

0 commit comments

Comments
 (0)