Skip to content

Commit 6a1ddb2

Browse files
derrickstoleedscho
authored andcommitted
survey: show progress during object walk
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 92bc5eb commit 6a1ddb2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

builtin/survey.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ static int survey_objects_path_walk_fn(const char *path,
628628
type, oids->nr);
629629
increment_object_totals(ctx, oids, type);
630630

631+
ctx->progress_nr += oids->nr;
632+
display_progress(ctx->progress, ctx->progress_nr);
633+
631634
return 0;
632635
}
633636

@@ -657,13 +660,24 @@ static void survey_phase_objects(struct survey_context *ctx)
657660
repo_init_revisions(ctx->repo, &revs, "");
658661
revs.tag_objects = 1;
659662

663+
ctx->progress_nr = 0;
664+
ctx->progress_total = ctx->ref_array.nr;
665+
if (ctx->opts.show_progress)
666+
ctx->progress = start_progress(_("Preparing object walk"),
667+
ctx->progress_total);
660668
for (int i = 0; i < ctx->ref_array.nr; i++) {
661669
struct ref_array_item *item = ctx->ref_array.items[i];
662670
add_pending_oid(&revs, NULL, &item->objectname, add_flags);
663671
display_progress(ctx->progress, ++(ctx->progress_nr));
664672
}
673+
stop_progress(&ctx->progress);
665674

675+
ctx->progress_nr = 0;
676+
ctx->progress_total = 0;
677+
if (ctx->opts.show_progress)
678+
ctx->progress = start_progress(_("Walking objects"), 0);
666679
walk_objects_by_path(&info);
680+
stop_progress(&ctx->progress);
667681

668682
release_revisions(&revs);
669683
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
test_expect_success 'git survey (default)' '
2934
git survey --all-refs >out 2>err &&
3035
test_line_count = 0 err &&

0 commit comments

Comments
 (0)