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

midx: use start_delayed_progress()

Now that the multi-pack-index may be written as part of auto maintenance at the end of a command, reduce the progress output when the operations are quick. Use start_delayed_progress() instead of start_progress(). Update t5319-multi-pack-index.sh to use GIT_PROGRESS_DELAY=0 now that the progress indicators are conditional. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Sep 25, 2020 at 12:33 UTC efdd2f0d4c4d6b1b1090171b6428919038bd2980
2 files changed +12 -12
midx.c
+5 -5
@@ -832,7 +832,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
832
833 packs.pack_paths_checked = 0;
834 if (flags & MIDX_PROGRESS)
835 - packs.progress = start_progress(_("Adding packfiles to multi-pack-index"), 0);
835 + packs.progress = start_delayed_progress(_("Adding packfiles to multi-pack-index"), 0);
836 else
837 packs.progress = NULL;
838
@@ -969,7 +969,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
969 }
970
971 if (flags & MIDX_PROGRESS)
972 - progress = start_progress(_("Writing chunks to multi-pack-index"),
972 + progress = start_delayed_progress(_("Writing chunks to multi-pack-index"),
973 num_chunks);
974 for (i = 0; i < num_chunks; i++) {
975 if (written != chunk_offsets[i])
@@ -1104,7 +1104,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
1104 return 0;
1105
1106 if (flags & MIDX_PROGRESS)
1107 - progress = start_progress(_("Looking for referenced packfiles"),
1107 + progress = start_delayed_progress(_("Looking for referenced packfiles"),
1108 m->num_packs);
1109 for (i = 0; i < m->num_packs; i++) {
1110 if (prepare_midx_pack(r, m, i))
@@ -1225,7 +1225,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1225 count = xcalloc(m->num_packs, sizeof(uint32_t));
1226
1227 if (flags & MIDX_PROGRESS)
1228 - progress = start_progress(_("Counting referenced objects"),
1228 + progress = start_delayed_progress(_("Counting referenced objects"),
1229 m->num_objects);
1230 for (i = 0; i < m->num_objects; i++) {
1231 int pack_int_id = nth_midxed_pack_int_id(m, i);
@@ -1235,7 +1235,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1235 stop_progress(&progress);
1236
1237 if (flags & MIDX_PROGRESS)
1238 - progress = start_progress(_("Finding and deleting unreferenced packfiles"),
1238 + progress = start_delayed_progress(_("Finding and deleting unreferenced packfiles"),
1239 m->num_packs);
1240 for (i = 0; i < m->num_packs; i++) {
1241 char *pack_name;
t/t5319-multi-pack-index.sh
+7 -7
@@ -171,12 +171,12 @@ test_expect_success 'write progress off for redirected stderr' '
171 '
172
173 test_expect_success 'write force progress on for stderr' '
174 - git multi-pack-index --object-dir=$objdir --progress write 2>err &&
174 + GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress write 2>err &&
175 test_file_not_empty err
176 '
177
178 test_expect_success 'write with the --no-progress option' '
179 - git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
179 + GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
180 test_line_count = 0 err
181 '
182
@@ -333,17 +333,17 @@ test_expect_success 'git-fsck incorrect offset' '
333 '
334
335 test_expect_success 'repack progress off for redirected stderr' '
336 - git multi-pack-index --object-dir=$objdir repack 2>err &&
336 + GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack 2>err &&
337 test_line_count = 0 err
338 '
339
340 test_expect_success 'repack force progress on for stderr' '
341 - git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
341 + GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
342 test_file_not_empty err
343 '
344
345 test_expect_success 'repack with the --no-progress option' '
346 - git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
346 + GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
347 test_line_count = 0 err
348 '
349
@@ -487,7 +487,7 @@ test_expect_success 'expire progress off for redirected stderr' '
487 test_expect_success 'expire force progress on for stderr' '
488 (
489 cd dup &&
490 - git multi-pack-index --progress expire 2>err &&
490 + GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
491 test_file_not_empty err
492 )
493 '
@@ -495,7 +495,7 @@ test_expect_success 'expire force progress on for stderr' '
495 test_expect_success 'expire with the --no-progress option' '
496 (
497 cd dup &&
498 - git multi-pack-index --no-progress expire 2>err &&
498 + GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
499 test_line_count = 0 err
500 )
501 '