Skip to content

Commit 8dc18f8

Browse files
wilbakergitster
authored andcommitted
midx: add progress to expire_midx_packs
Add progress to expire_midx_packs. Progress is displayed when the MIDX_PROGRESS flag is set. Signed-off-by: William Baker <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 840cef0 commit 8dc18f8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

midx.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,18 +1205,29 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
12051205
uint32_t i, *count, result = 0;
12061206
struct string_list packs_to_drop = STRING_LIST_INIT_DUP;
12071207
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
1208+
struct progress *progress = NULL;
12081209

12091210
if (!m)
12101211
return 0;
12111212

12121213
count = xcalloc(m->num_packs, sizeof(uint32_t));
1214+
1215+
if (flags & MIDX_PROGRESS)
1216+
progress = start_progress(_("Counting referenced objects"),
1217+
m->num_objects);
12131218
for (i = 0; i < m->num_objects; i++) {
12141219
int pack_int_id = nth_midxed_pack_int_id(m, i);
12151220
count[pack_int_id]++;
1221+
display_progress(progress, i + 1);
12161222
}
1223+
stop_progress(&progress);
12171224

1225+
if (flags & MIDX_PROGRESS)
1226+
progress = start_progress(_("Finding and deleting unreferenced packfiles"),
1227+
m->num_packs);
12181228
for (i = 0; i < m->num_packs; i++) {
12191229
char *pack_name;
1230+
display_progress(progress, i + 1);
12201231

12211232
if (count[i])
12221233
continue;
@@ -1234,6 +1245,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
12341245
unlink_pack_path(pack_name, 0);
12351246
free(pack_name);
12361247
}
1248+
stop_progress(&progress);
12371249

12381250
free(count);
12391251

0 commit comments

Comments
 (0)