Skip to content

Commit fb91fcf

Browse files
committed
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>
1 parent eb8c591 commit fb91fcf

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

midx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
832832

833833
packs.pack_paths_checked = 0;
834834
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);
836836
else
837837
packs.progress = NULL;
838838

@@ -969,7 +969,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
969969
}
970970

971971
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"),
973973
num_chunks);
974974
for (i = 0; i < num_chunks; i++) {
975975
if (written != chunk_offsets[i])
@@ -1104,7 +1104,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
11041104
return 0;
11051105

11061106
if (flags & MIDX_PROGRESS)
1107-
progress = start_progress(_("Looking for referenced packfiles"),
1107+
progress = start_delayed_progress(_("Looking for referenced packfiles"),
11081108
m->num_packs);
11091109
for (i = 0; i < m->num_packs; i++) {
11101110
if (prepare_midx_pack(r, m, i))
@@ -1225,7 +1225,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
12251225
count = xcalloc(m->num_packs, sizeof(uint32_t));
12261226

12271227
if (flags & MIDX_PROGRESS)
1228-
progress = start_progress(_("Counting referenced objects"),
1228+
progress = start_delayed_progress(_("Counting referenced objects"),
12291229
m->num_objects);
12301230
for (i = 0; i < m->num_objects; i++) {
12311231
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
12351235
stop_progress(&progress);
12361236

12371237
if (flags & MIDX_PROGRESS)
1238-
progress = start_progress(_("Finding and deleting unreferenced packfiles"),
1238+
progress = start_delayed_progress(_("Finding and deleting unreferenced packfiles"),
12391239
m->num_packs);
12401240
for (i = 0; i < m->num_packs; i++) {
12411241
char *pack_name;

t/t5319-multi-pack-index.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ test_expect_success 'write progress off for redirected stderr' '
173173
'
174174

175175
test_expect_success 'write force progress on for stderr' '
176-
git multi-pack-index --object-dir=$objdir --progress write 2>err &&
176+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress write 2>err &&
177177
test_file_not_empty err
178178
'
179179

180180
test_expect_success 'write with the --no-progress option' '
181-
git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
181+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
182182
test_line_count = 0 err
183183
'
184184

@@ -335,17 +335,17 @@ test_expect_success 'git-fsck incorrect offset' '
335335
'
336336

337337
test_expect_success 'repack progress off for redirected stderr' '
338-
git multi-pack-index --object-dir=$objdir repack 2>err &&
338+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack 2>err &&
339339
test_line_count = 0 err
340340
'
341341

342342
test_expect_success 'repack force progress on for stderr' '
343-
git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
343+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
344344
test_file_not_empty err
345345
'
346346

347347
test_expect_success 'repack with the --no-progress option' '
348-
git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
348+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
349349
test_line_count = 0 err
350350
'
351351

@@ -489,15 +489,15 @@ test_expect_success 'expire progress off for redirected stderr' '
489489
test_expect_success 'expire force progress on for stderr' '
490490
(
491491
cd dup &&
492-
git multi-pack-index --progress expire 2>err &&
492+
GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
493493
test_file_not_empty err
494494
)
495495
'
496496

497497
test_expect_success 'expire with the --no-progress option' '
498498
(
499499
cd dup &&
500-
git multi-pack-index --no-progress expire 2>err &&
500+
GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
501501
test_line_count = 0 err
502502
)
503503
'

0 commit comments

Comments
 (0)