@matheusbsbs / matheus-bagliano / commits / ad60096d1c
Fork 0

midx: honor the MIDX_PROGRESS flag in verify_midx_file

Update verify_midx_file to only display progress 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 ad60096d1c82a6e05a01bb33c12cd1070bf01b4f
1 file changed +12 -8
midx.c
+12 -8
@@ -1097,15 +1097,16 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
1097 {
1098 struct pair_pos_vs_id *pairs = NULL;
1099 uint32_t i;
1100 - struct progress *progress;
1100 + struct progress *progress = NULL;
1101 struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
1102 verify_midx_error = 0;
1103
1104 if (!m)
1105 return 0;
1106
1107 - progress = start_progress(_("Looking for referenced packfiles"),
1108 - m->num_packs);
1107 + if (flags & MIDX_PROGRESS)
1108 + progress = start_progress(_("Looking for referenced packfiles"),
1109 + m->num_packs);
1110 for (i = 0; i < m->num_packs; i++) {
1111 if (prepare_midx_pack(r, m, i))
1112 midx_report("failed to load pack in position %d", i);
@@ -1123,8 +1124,9 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
1124 i, oid_fanout1, oid_fanout2, i + 1);
1125 }
1126
1126 - progress = start_sparse_progress(_("Verifying OID order in MIDX"),
1127 - m->num_objects - 1);
1127 + if (flags & MIDX_PROGRESS)
1128 + progress = start_sparse_progress(_("Verifying OID order in multi-pack-index"),
1129 + m->num_objects - 1);
1130 for (i = 0; i < m->num_objects - 1; i++) {
1131 struct object_id oid1, oid2;
1132
@@ -1151,13 +1153,15 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
1153 pairs[i].pack_int_id = nth_midxed_pack_int_id(m, i);
1154 }
1155
1154 - progress = start_sparse_progress(_("Sorting objects by packfile"),
1155 - m->num_objects);
1156 + if (flags & MIDX_PROGRESS)
1157 + progress = start_sparse_progress(_("Sorting objects by packfile"),
1158 + m->num_objects);
1159 display_progress(progress, 0); /* TODO: Measure QSORT() progress */
1160 QSORT(pairs, m->num_objects, compare_pair_pos_vs_id);
1161 stop_progress(&progress);
1162
1160 - progress = start_sparse_progress(_("Verifying object offsets"), m->num_objects);
1163 + if (flags & MIDX_PROGRESS)
1164 + progress = start_sparse_progress(_("Verifying object offsets"), m->num_objects);
1165 for (i = 0; i < m->num_objects; i++) {
1166 struct object_id oid;
1167 struct pack_entry e;