Skip to content

Commit 454ea2e

Browse files
derrickstoleegitster
authored andcommitted
treewide: use get_all_packs
There are many places in the codebase that want to iterate over all packfiles known to Git. The purposes are wide-ranging, and those that can take advantage of the multi-pack-index already do. So, use get_all_packs() instead of get_packed_git() to be sure we are iterating over all packfiles. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bff526 commit 454ea2e

File tree

11 files changed

+23
-23
lines changed

11 files changed

+23
-23
lines changed

builtin/count-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
123123
struct strbuf pack_buf = STRBUF_INIT;
124124
struct strbuf garbage_buf = STRBUF_INIT;
125125

126-
for (p = get_packed_git(the_repository); p; p = p->next) {
126+
for (p = get_all_packs(the_repository); p; p = p->next) {
127127
if (!p->pack_local)
128128
continue;
129129
if (open_pack_index(p))

builtin/fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
740740
struct progress *progress = NULL;
741741

742742
if (show_progress) {
743-
for (p = get_packed_git(the_repository); p;
743+
for (p = get_all_packs(the_repository); p;
744744
p = p->next) {
745745
if (open_pack_index(p))
746746
continue;
@@ -749,7 +749,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
749749

750750
progress = start_progress(_("Checking objects"), total);
751751
}
752-
for (p = get_packed_git(the_repository); p;
752+
for (p = get_all_packs(the_repository); p;
753753
p = p->next) {
754754
/* verify gives error messages itself */
755755
if (verify_pack(p, fsck_obj_buffer,

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static struct packed_git *find_base_packs(struct string_list *packs,
183183
{
184184
struct packed_git *p, *base = NULL;
185185

186-
for (p = get_packed_git(the_repository); p; p = p->next) {
186+
for (p = get_all_packs(the_repository); p; p = p->next) {
187187
if (!p->pack_local)
188188
continue;
189189
if (limit) {
@@ -208,7 +208,7 @@ static int too_many_packs(void)
208208
if (gc_auto_pack_limit <= 0)
209209
return 0;
210210

211-
for (cnt = 0, p = get_packed_git(the_repository); p; p = p->next) {
211+
for (cnt = 0, p = get_all_packs(the_repository); p; p = p->next) {
212212
if (!p->pack_local)
213213
continue;
214214
if (p->pack_keep)

builtin/pack-objects.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
28092809

28102810
memset(&in_pack, 0, sizeof(in_pack));
28112811

2812-
for (p = get_packed_git(the_repository); p; p = p->next) {
2812+
for (p = get_all_packs(the_repository); p; p = p->next) {
28132813
struct object_id oid;
28142814
struct object *o;
28152815

@@ -2873,7 +2873,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
28732873
struct packed_git *p;
28742874

28752875
p = (last_found != (void *)1) ? last_found :
2876-
get_packed_git(the_repository);
2876+
get_all_packs(the_repository);
28772877

28782878
while (p) {
28792879
if ((!p->pack_local || p->pack_keep ||
@@ -2883,7 +2883,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
28832883
return 1;
28842884
}
28852885
if (p == last_found)
2886-
p = get_packed_git(the_repository);
2886+
p = get_all_packs(the_repository);
28872887
else
28882888
p = p->next;
28892889
if (p == last_found)
@@ -2919,7 +2919,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
29192919
uint32_t i;
29202920
struct object_id oid;
29212921

2922-
for (p = get_packed_git(the_repository); p; p = p->next) {
2922+
for (p = get_all_packs(the_repository); p; p = p->next) {
29232923
if (!p->pack_local || p->pack_keep || p->pack_keep_in_core)
29242924
continue;
29252925

@@ -3066,7 +3066,7 @@ static void add_extra_kept_packs(const struct string_list *names)
30663066
if (!names->nr)
30673067
return;
30683068

3069-
for (p = get_packed_git(the_repository); p; p = p->next) {
3069+
for (p = get_all_packs(the_repository); p; p = p->next) {
30703070
const char *name = basename(p->pack_name);
30713071
int i;
30723072

@@ -3339,7 +3339,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
33393339
add_extra_kept_packs(&keep_pack_list);
33403340
if (ignore_packed_keep_on_disk) {
33413341
struct packed_git *p;
3342-
for (p = get_packed_git(the_repository); p; p = p->next)
3342+
for (p = get_all_packs(the_repository); p; p = p->next)
33433343
if (p->pack_local && p->pack_keep)
33443344
break;
33453345
if (!p) /* no keep-able packs found */
@@ -3352,7 +3352,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
33523352
* it also covers non-local objects
33533353
*/
33543354
struct packed_git *p;
3355-
for (p = get_packed_git(the_repository); p; p = p->next) {
3355+
for (p = get_all_packs(the_repository); p; p = p->next) {
33563356
if (!p->pack_local) {
33573357
have_non_local_packs = 1;
33583358
break;

builtin/pack-redundant.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static struct pack_list * add_pack(struct packed_git *p)
577577

578578
static struct pack_list * add_pack_file(const char *filename)
579579
{
580-
struct packed_git *p = get_packed_git(the_repository);
580+
struct packed_git *p = get_all_packs(the_repository);
581581

582582
if (strlen(filename) < 40)
583583
die("Bad pack filename: %s", filename);
@@ -592,7 +592,7 @@ static struct pack_list * add_pack_file(const char *filename)
592592

593593
static void load_all(void)
594594
{
595-
struct packed_git *p = get_packed_git(the_repository);
595+
struct packed_git *p = get_all_packs(the_repository);
596596

597597
while (p) {
598598
add_pack(p);

fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ static int store_object(
10681068
duplicate_count_by_type[type]++;
10691069
return 1;
10701070
} else if (find_sha1_pack(oid.hash,
1071-
get_packed_git(the_repository))) {
1071+
get_all_packs(the_repository))) {
10721072
e->type = type;
10731073
e->pack_id = MAX_PACK_ID;
10741074
e->idx.offset = 1; /* just not zero! */
@@ -1266,7 +1266,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
12661266
truncate_pack(&checkpoint);
12671267

12681268
} else if (find_sha1_pack(oid.hash,
1269-
get_packed_git(the_repository))) {
1269+
get_all_packs(the_repository))) {
12701270
e->type = OBJ_BLOB;
12711271
e->pack_id = MAX_PACK_ID;
12721272
e->idx.offset = 1; /* just not zero! */

http-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,13 @@ static void get_info_packs(struct strbuf *hdr, char *arg)
595595
size_t cnt = 0;
596596

597597
select_getanyfile(hdr);
598-
for (p = get_packed_git(the_repository); p; p = p->next) {
598+
for (p = get_all_packs(the_repository); p; p = p->next) {
599599
if (p->pack_local)
600600
cnt++;
601601
}
602602

603603
strbuf_grow(&buf, cnt * 53 + 2);
604-
for (p = get_packed_git(the_repository); p; p = p->next) {
604+
for (p = get_all_packs(the_repository); p; p = p->next) {
605605
if (p->pack_local)
606606
strbuf_addf(&buf, "P %s\n", p->pack_name + objdirlen + 6);
607607
}

pack-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)
335335

336336
assert(!bitmap_git->map && !bitmap_git->loaded);
337337

338-
for (p = get_packed_git(the_repository); p; p = p->next) {
338+
for (p = get_all_packs(the_repository); p; p = p->next) {
339339
if (open_pack_bitmap_1(bitmap_git, p) == 0)
340340
ret = 0;
341341
}

pack-objects.c

Lines changed: 1 addition & 1 deletion
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_packed_git(the_repository); p; p = p->next, cnt++) {
102+
for (p = get_all_packs(the_repository); p; p = p->next, cnt++) {
103103
if (cnt == nr) {
104104
free(mapping);
105105
return;

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
20362036
int pack_errors = 0;
20372037

20382038
prepare_packed_git(the_repository);
2039-
for (p = the_repository->objects->packed_git; p; p = p->next) {
2039+
for (p = get_all_packs(the_repository); p; p = p->next) {
20402040
if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
20412041
continue;
20422042
if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&

server-info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void init_pack_info(const char *infofile, int force)
199199
objdir = get_object_directory();
200200
objdirlen = strlen(objdir);
201201

202-
for (p = get_packed_git(the_repository); p; p = p->next) {
202+
for (p = get_all_packs(the_repository); p; p = p->next) {
203203
/* we ignore things on alternate path since they are
204204
* not available to the pullers in general.
205205
*/
@@ -209,7 +209,7 @@ static void init_pack_info(const char *infofile, int force)
209209
}
210210
num_pack = i;
211211
info = xcalloc(num_pack, sizeof(struct pack_info *));
212-
for (i = 0, p = get_packed_git(the_repository); p; p = p->next) {
212+
for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
213213
if (!p->pack_local)
214214
continue;
215215
info[i] = xcalloc(1, sizeof(struct pack_info));

0 commit comments

Comments
 (0)