diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-11-10 08:49:08 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-12 08:50:06 +0300 |
commit | 7c14112741b81366cfbbc3b98e0b92422fcce83d (patch) | |
tree | 25ea81f5000e4f9cdf5b80b39c00a1021c917188 | |
parent | 94e10825bd72660548956a6d5fb260642ffb6386 (diff) |
pack-*.c: remove the_repository references
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/pack-objects.c | 2 | ||||
-rw-r--r-- | pack-bitmap-write.c | 6 | ||||
-rw-r--r-- | pack-bitmap.c | 13 | ||||
-rw-r--r-- | pack-bitmap.h | 3 | ||||
-rw-r--r-- | pack-objects.c | 6 | ||||
-rw-r--r-- | pack-objects.h | 5 |
6 files changed, 21 insertions, 14 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 7812c2b1f3..8abfb69e2d 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3481,7 +3481,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } } - prepare_packing_data(&to_pack); + prepare_packing_data(the_repository, &to_pack); if (progress) progress_state = start_progress(_("Enumerating objects"), 0); diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 9d1b951697..5566e94abe 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -77,7 +77,7 @@ void bitmap_writer_build_type_index(struct packing_data *to_pack, break; default: - real_type = oid_object_info(the_repository, + real_type = oid_object_info(to_pack->repo, &entry->idx.oid, NULL); break; } @@ -262,7 +262,7 @@ void bitmap_writer_build(struct packing_data *to_pack) if (writer.show_progress) writer.progress = start_progress("Building bitmaps", writer.selected_nr); - repo_init_revisions(the_repository, &revs, NULL); + repo_init_revisions(to_pack->repo, &revs, NULL); revs.tag_objects = 1; revs.tree_objects = 1; revs.blob_objects = 1; @@ -363,7 +363,7 @@ static int date_compare(const void *_a, const void *_b) void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack) { struct bitmap_index *bitmap_git; - if (!(bitmap_git = prepare_bitmap_git())) + if (!(bitmap_git = prepare_bitmap_git(to_pack->repo))) return; writer.reused = kh_init_sha1(); diff --git a/pack-bitmap.c b/pack-bitmap.c index 5848cc93aa..4695aaf6b4 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -328,14 +328,15 @@ failed: return -1; } -static int open_pack_bitmap(struct bitmap_index *bitmap_git) +static int open_pack_bitmap(struct repository *r, + struct bitmap_index *bitmap_git) { struct packed_git *p; int ret = -1; assert(!bitmap_git->map); - for (p = get_all_packs(the_repository); p; p = p->next) { + for (p = get_all_packs(r); p; p = p->next) { if (open_pack_bitmap_1(bitmap_git, p) == 0) ret = 0; } @@ -343,11 +344,11 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git) return ret; } -struct bitmap_index *prepare_bitmap_git(void) +struct bitmap_index *prepare_bitmap_git(struct repository *r) { struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git)); - if (!open_pack_bitmap(bitmap_git) && !load_pack_bitmap(bitmap_git)) + if (!open_pack_bitmap(r, bitmap_git) && !load_pack_bitmap(bitmap_git)) return bitmap_git; free_bitmap_index(bitmap_git); @@ -690,7 +691,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs) struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git)); /* try to open a bitmapped pack, but don't parse it yet * because we may not need to use it */ - if (open_pack_bitmap(bitmap_git) < 0) + if (open_pack_bitmap(revs->repo, bitmap_git) < 0) goto cleanup; for (i = 0; i < revs->pending.nr; ++i) { @@ -955,7 +956,7 @@ void test_bitmap_walk(struct rev_info *revs) struct bitmap_test_data tdata; struct bitmap_index *bitmap_git; - if (!(bitmap_git = prepare_bitmap_git())) + if (!(bitmap_git = prepare_bitmap_git(revs->repo))) die("failed to load bitmap indexes"); if (revs->pending.nr != 1) diff --git a/pack-bitmap.h b/pack-bitmap.h index 189dd68ad3..8418ba8c79 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -6,6 +6,7 @@ #include "pack-objects.h" struct commit; +struct repository; struct rev_info; struct bitmap_disk_header { @@ -39,7 +40,7 @@ typedef int (*show_reachable_fn)( struct bitmap_index; -struct bitmap_index *prepare_bitmap_git(void); +struct bitmap_index *prepare_bitmap_git(struct repository *r); void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits, uint32_t *trees, uint32_t *blobs, uint32_t *tags); void traverse_bitmap_commit_list(struct bitmap_index *, diff --git a/pack-objects.c b/pack-objects.c index b6cdbb0166..9c45842df3 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata) * (i.e. in_pack_idx also zero) should return NULL. */ mapping[cnt++] = NULL; - for (p = get_all_packs(the_repository); p; p = p->next, cnt++) { + for (p = get_all_packs(pdata->repo); p; p = p->next, cnt++) { if (cnt == nr) { free(mapping); return; @@ -133,8 +133,10 @@ void oe_map_new_pack(struct packing_data *pack, } /* assume pdata is already zero'd by caller */ -void prepare_packing_data(struct packing_data *pdata) +void prepare_packing_data(struct repository *r, struct packing_data *pdata) { + pdata->repo = r; + if (git_env_bool("GIT_TEST_FULL_IN_PACK_ARRAY", 0)) { /* * do not initialize in_pack_by_idx[] to force the diff --git a/pack-objects.h b/pack-objects.h index 86ee93feb4..9e6af3f24f 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -5,6 +5,8 @@ #include "thread-utils.h" #include "pack.h" +struct repository; + #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024) #define OE_DFS_STATE_BITS 2 @@ -127,6 +129,7 @@ struct object_entry { }; struct packing_data { + struct repository *repo; struct object_entry *objects; uint32_t nr_objects, nr_alloc; @@ -165,7 +168,7 @@ struct packing_data { unsigned char *layer; }; -void prepare_packing_data(struct packing_data *pdata); +void prepare_packing_data(struct repository *r, struct packing_data *pdata); static inline void packing_data_lock(struct packing_data *pdata) { |