@matheusbsbs / matheus-bagliano / commits / 8dc18f8937
Fork 0

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 <William.Baker@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

William Baker committed Oct 21, 2019 at 18:40 UTC 8dc18f8937faf542da785b28062731ddfbfee974
1 file changed +12
midx.c
+12
@@ -1205,18 +1205,29 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1205 uint32_t i, *count, result = 0;
1206 struct string_list packs_to_drop = STRING_LIST_INIT_DUP;
1207 struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
1208 + struct progress *progress = NULL;
1209
1210 if (!m)
1211 return 0;
1212
1213 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);
1218 for (i = 0; i < m->num_objects; i++) {
1219 int pack_int_id = nth_midxed_pack_int_id(m, i);
1220 count[pack_int_id]++;
1221 + display_progress(progress, i + 1);
1222 }
1223 + stop_progress(&progress);
1224
1225 + if (flags & MIDX_PROGRESS)
1226 + progress = start_progress(_("Finding and deleting unreferenced packfiles"),
1227 + m->num_packs);
1228 for (i = 0; i < m->num_packs; i++) {
1229 char *pack_name;
1230 + display_progress(progress, i + 1);
1231
1232 if (count[i])
1233 continue;
@@ -1234,6 +1245,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1245 unlink_pack_path(pack_name, 0);
1246 free(pack_name);
1247 }
1248 + stop_progress(&progress);
1249
1250 free(count);
1251