Skip to content

Commit 785f938

Browse files
derrickstoleedscho
authored andcommitted
survey: show progress during object walk
Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent b954863 commit 785f938

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

builtin/survey.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ static int survey_objects_path_walk_fn(const char *path UNUSED,
630630
type, oids->nr);
631631
increment_object_totals(ctx, oids, type);
632632

633+
ctx->progress_nr += oids->nr;
634+
display_progress(ctx->progress, ctx->progress_nr);
635+
633636
return 0;
634637
}
635638

@@ -659,13 +662,26 @@ static void survey_phase_objects(struct survey_context *ctx)
659662
repo_init_revisions(ctx->repo, &revs, "");
660663
revs.tag_objects = 1;
661664

665+
ctx->progress_nr = 0;
666+
ctx->progress_total = ctx->ref_array.nr;
667+
if (ctx->opts.show_progress)
668+
ctx->progress = start_progress(ctx->repo,
669+
_("Preparing object walk"),
670+
ctx->progress_total);
662671
for (int i = 0; i < ctx->ref_array.nr; i++) {
663672
struct ref_array_item *item = ctx->ref_array.items[i];
664673
add_pending_oid(&revs, NULL, &item->objectname, add_flags);
665674
display_progress(ctx->progress, ++(ctx->progress_nr));
666675
}
676+
stop_progress(&ctx->progress);
667677

678+
ctx->progress_nr = 0;
679+
ctx->progress_total = 0;
680+
if (ctx->opts.show_progress)
681+
ctx->progress = start_progress(ctx->repo,
682+
_("Walking objects"), 0);
668683
walk_objects_by_path(&info);
684+
stop_progress(&ctx->progress);
669685

670686
release_revisions(&revs);
671687
trace2_region_leave("survey", "phase/objects", ctx->repo);

t/t8100-git-survey.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ test_expect_success 'create a semi-interesting repo' '
2525
git update-ref -d refs/tags/two
2626
'
2727

28+
test_expect_success 'git survey --progress' '
29+
GIT_PROGRESS_DELAY=0 git survey --all-refs --progress >out 2>err &&
30+
grep "Preparing object walk" err
31+
'
32+
2833
approximate_sizes() {
2934
# very simplistic approximate rounding
3035
sed -Ee "s/ *(1[0-9][0-9])( |$)/ ~0.1kB\2/g" \

0 commit comments

Comments
 (0)