Skip to content

Commit 671fc2d

Browse files
committed
survey: show progress during object walk
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 608e785 commit 671fc2d

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
@@ -632,6 +632,9 @@ static int survey_objects_path_walk_fn(const char *path UNUSED,
632632
type, oids->nr);
633633
increment_object_totals(ctx, oids, type);
634634

635+
ctx->progress_nr += oids->nr;
636+
display_progress(ctx->progress, ctx->progress_nr);
637+
635638
return 0;
636639
}
637640

@@ -661,13 +664,24 @@ static void survey_phase_objects(struct survey_context *ctx)
661664
repo_init_revisions(ctx->repo, &revs, "");
662665
revs.tag_objects = 1;
663666

667+
ctx->progress_nr = 0;
668+
ctx->progress_total = ctx->ref_array.nr;
669+
if (ctx->opts.show_progress)
670+
ctx->progress = start_progress(_("Preparing object walk"),
671+
ctx->progress_total);
664672
for (size_t i = 0; i < ctx->ref_array.nr; i++) {
665673
struct ref_array_item *item = ctx->ref_array.items[i];
666674
add_pending_oid(&revs, NULL, &item->objectname, add_flags);
667675
display_progress(ctx->progress, ++(ctx->progress_nr));
668676
}
677+
stop_progress(&ctx->progress);
669678

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

672686
release_revisions(&revs);
673687
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)