Skip to content

Commit

Permalink
survey: show progress during object walk
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Stolee <stolee@gmail.com>
  • Loading branch information
derrickstolee authored and Git for Windows Build Agent committed Oct 10, 2024
1 parent f99d715 commit 37454e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions builtin/survey.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ static int survey_objects_path_walk_fn(const char *path,
type, oids->nr);
increment_object_totals(ctx, oids, type);

ctx->progress_nr += oids->nr;
display_progress(ctx->progress, ctx->progress_nr);

return 0;
}

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

ctx->progress_nr = 0;
ctx->progress_total = ctx->ref_array.nr;
if (ctx->opts.show_progress)
ctx->progress = start_progress(_("Preparing object walk"),
ctx->progress_total);
for (size_t i = 0; i < ctx->ref_array.nr; i++) {
struct ref_array_item *item = ctx->ref_array.items[i];
add_pending_oid(&revs, NULL, &item->objectname, add_flags);
display_progress(ctx->progress, ++(ctx->progress_nr));
}
stop_progress(&ctx->progress);

ctx->progress_nr = 0;
ctx->progress_total = 0;
if (ctx->opts.show_progress)
ctx->progress = start_progress(_("Walking objects"), 0);
walk_objects_by_path(&info);
stop_progress(&ctx->progress);

release_revisions(&revs);
trace2_region_leave("survey", "phase/objects", ctx->repo);
Expand Down
5 changes: 5 additions & 0 deletions t/t8100-git-survey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ test_expect_success 'create a semi-interesting repo' '
git update-ref -d refs/tags/two
'

test_expect_success 'git survey --progress' '
GIT_PROGRESS_DELAY=0 git survey --all-refs --progress >out 2>err &&
grep "Preparing object walk" err
'

test_expect_success 'git survey (default)' '
git survey --all-refs >out 2>err &&
test_line_count = 0 err &&
Expand Down

0 comments on commit 37454e6

Please sign in to comment.