Skip to content

Commit fa7b912

Browse files
pks-tgitster
authored andcommitted
repack-promisor: extract function to remove redundant packs
We're about to add a second caller that wants to remove redundant packs after a geometric repack. Split out the function which does this to prepare for that. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent dd8c4e1 commit fa7b912

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

repack-geometry.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@ struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry)
197197
return NULL;
198198
}
199199

200-
void pack_geometry_remove_redundant(struct pack_geometry *geometry,
201-
struct string_list *names,
202-
struct existing_packs *existing,
203-
const char *packdir)
200+
static void remove_redundant_packs(struct packed_git **pack,
201+
uint32_t pack_nr,
202+
struct string_list *names,
203+
struct existing_packs *existing,
204+
const char *packdir)
204205
{
205206
const struct git_hash_algo *algop = existing->repo->hash_algo;
206207
struct strbuf buf = STRBUF_INIT;
207208
uint32_t i;
208209

209-
for (i = 0; i < geometry->split; i++) {
210-
struct packed_git *p = geometry->pack[i];
210+
for (i = 0; i < pack_nr; i++) {
211+
struct packed_git *p = pack[i];
211212
if (string_list_has_string(names, hash_to_hex_algop(p->hash,
212213
algop)))
213214
continue;
@@ -226,6 +227,15 @@ void pack_geometry_remove_redundant(struct pack_geometry *geometry,
226227
strbuf_release(&buf);
227228
}
228229

230+
void pack_geometry_remove_redundant(struct pack_geometry *geometry,
231+
struct string_list *names,
232+
struct existing_packs *existing,
233+
const char *packdir)
234+
{
235+
remove_redundant_packs(geometry->pack, geometry->split,
236+
names, existing, packdir);
237+
}
238+
229239
void pack_geometry_release(struct pack_geometry *geometry)
230240
{
231241
if (!geometry)

0 commit comments

Comments
 (0)