Skip to content

Commit

Permalink
midx: use start_delayed_progress()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
derrickstolee committed Jul 7, 2020
1 parent fbe03b9 commit f7fdf72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions midx.c
Expand Up @@ -837,7 +837,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *

packs.pack_paths_checked = 0;
if (flags & MIDX_PROGRESS)
packs.progress = start_progress(_("Adding packfiles to multi-pack-index"), 0);
packs.progress = start_delayed_progress(_("Adding packfiles to multi-pack-index"), 0);
else
packs.progress = NULL;

Expand Down Expand Up @@ -974,7 +974,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
}

if (flags & MIDX_PROGRESS)
progress = start_progress(_("Writing chunks to multi-pack-index"),
progress = start_delayed_progress(_("Writing chunks to multi-pack-index"),
num_chunks);
for (i = 0; i < num_chunks; i++) {
if (written != chunk_offsets[i])
Expand Down Expand Up @@ -1109,7 +1109,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
return 0;

if (flags & MIDX_PROGRESS)
progress = start_progress(_("Looking for referenced packfiles"),
progress = start_delayed_progress(_("Looking for referenced packfiles"),
m->num_packs);
for (i = 0; i < m->num_packs; i++) {
if (prepare_midx_pack(r, m, i))
Expand Down Expand Up @@ -1230,7 +1230,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
count = xcalloc(m->num_packs, sizeof(uint32_t));

if (flags & MIDX_PROGRESS)
progress = start_progress(_("Counting referenced objects"),
progress = start_delayed_progress(_("Counting referenced objects"),
m->num_objects);
for (i = 0; i < m->num_objects; i++) {
int pack_int_id = nth_midxed_pack_int_id(m, i);
Expand All @@ -1240,7 +1240,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
stop_progress(&progress);

if (flags & MIDX_PROGRESS)
progress = start_progress(_("Finding and deleting unreferenced packfiles"),
progress = start_delayed_progress(_("Finding and deleting unreferenced packfiles"),
m->num_packs);
for (i = 0; i < m->num_packs; i++) {
char *pack_name;
Expand Down
14 changes: 7 additions & 7 deletions t/t5319-multi-pack-index.sh
Expand Up @@ -172,12 +172,12 @@ test_expect_success 'write progress off for redirected stderr' '
'

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

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

Expand Down Expand Up @@ -334,17 +334,17 @@ test_expect_success 'git-fsck incorrect offset' '
'

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

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

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

Expand Down Expand Up @@ -488,15 +488,15 @@ test_expect_success 'expire progress off for redirected stderr' '
test_expect_success 'expire force progress on for stderr' '
(
cd dup &&
git multi-pack-index --progress expire 2>err &&
GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
test_file_not_empty err
)
'

test_expect_success 'expire with the --no-progress option' '
(
cd dup &&
git multi-pack-index --no-progress expire 2>err &&
GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
test_line_count = 0 err
)
'
Expand Down

0 comments on commit f7fdf72

Please sign in to comment.