Skip to content

Commit 751808b

Browse files
pks-tgitster
authored andcommitted
packfile: refactor get_packed_git() to work on packfile store
The `get_packed_git()` function prepares the packfile store and then returns its packfiles. Refactor it to accept a packfile store instead of a repository to clarify its scope. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab8aff4 commit 751808b

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED)
14231423
if (incremental_repack_auto_limit < 0)
14241424
return 1;
14251425

1426-
for (p = get_packed_git(the_repository);
1426+
for (p = packfile_store_get_packs(the_repository->objects->packfiles);
14271427
count < incremental_repack_auto_limit && p;
14281428
p = p->next) {
14291429
if (!p->multi_pack_index)

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ int cmd_grep(int argc,
12141214
if (recurse_submodules)
12151215
repo_read_gitmodules(the_repository, 1);
12161216
if (startup_info->have_repository)
1217-
(void)get_packed_git(the_repository);
1217+
(void)packfile_store_get_packs(the_repository->objects->packfiles);
12181218

12191219
start_threads(&opt);
12201220
} else {

object-name.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static void find_short_packed_object(struct disambiguate_state *ds)
213213
unique_in_midx(m, ds);
214214
}
215215

216-
for (p = get_packed_git(ds->repo); p && !ds->ambiguous;
216+
for (p = packfile_store_get_packs(ds->repo->objects->packfiles); p && !ds->ambiguous;
217217
p = p->next)
218218
unique_in_pack(p, ds);
219219
}
@@ -806,7 +806,7 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)
806806
find_abbrev_len_for_midx(m, mad);
807807
}
808808

809-
for (p = get_packed_git(mad->repo); p; p = p->next)
809+
for (p = packfile_store_get_packs(mad->repo->objects->packfiles); p; p = p->next)
810810
find_abbrev_len_for_pack(p, mad);
811811
}
812812

packfile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,10 @@ void packfile_store_reprepare(struct packfile_store *store)
10271027
packfile_store_prepare(store);
10281028
}
10291029

1030-
struct packed_git *get_packed_git(struct repository *r)
1030+
struct packed_git *packfile_store_get_packs(struct packfile_store *store)
10311031
{
1032-
packfile_store_prepare(r->objects->packfiles);
1033-
return r->objects->packfiles->packs;
1032+
packfile_store_prepare(store);
1033+
return store->packs;
10341034
}
10351035

10361036
struct packed_git *get_all_packs(struct repository *r)

packfile.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ void packfile_store_reprepare(struct packfile_store *store);
136136
void packfile_store_add_pack(struct packfile_store *store,
137137
struct packed_git *pack);
138138

139+
/*
140+
* Get packs managed by the given store. Does not load the MIDX or any packs
141+
* referenced by it.
142+
*/
143+
struct packed_git *packfile_store_get_packs(struct packfile_store *store);
144+
139145
/*
140146
* Open the packfile and add it to the store if it isn't yet known. Returns
141147
* either the newly opened packfile or the preexisting packfile. Returns a
@@ -220,7 +226,6 @@ int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
220226
#define PACKDIR_FILE_GARBAGE 4
221227
extern void (*report_garbage)(unsigned seen_bits, const char *path);
222228

223-
struct packed_git *get_packed_git(struct repository *r);
224229
struct list_head *get_packed_git_mru(struct repository *r);
225230
struct packed_git *get_all_packs(struct repository *r);
226231

0 commit comments

Comments
 (0)