progress: stop using `the_repository`

Stop using `the_repository` in the "progress" subsystem by passing in a
repository when initializing `struct progress`. Furthermore, store a
pointer to the repository in that struct so that we can pass it to the
trace2 API when logging information.

Adjust callers accordingly by using `the_repository`. While there may be
some callers that have a repository available in their context, this
trivial conversion allows for easier verification and bubbles up the use
of `the_repository` by one level.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2024-12-17 07:43:48 +01:00 committed by Junio C Hamano
parent 913a1e157c
commit 1f7e6478dc
27 changed files with 136 additions and 59 deletions

View File

@ -1193,7 +1193,9 @@ parse_done:
sb.found_guilty_entry = &found_guilty_entry; sb.found_guilty_entry = &found_guilty_entry;
sb.found_guilty_entry_data = &pi; sb.found_guilty_entry_data = &pi;
if (show_progress) if (show_progress)
pi.progress = start_delayed_progress(_("Blaming lines"), num_lines); pi.progress = start_delayed_progress(the_repository,
_("Blaming lines"),
num_lines);


assign_blame(&sb, opt); assign_blame(&sb, opt);



View File

@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
oidset_init(&commits, 0); oidset_init(&commits, 0);
if (opts.progress) if (opts.progress)
progress = start_delayed_progress( progress = start_delayed_progress(
the_repository,
_("Collecting commits from input"), 0); _("Collecting commits from input"), 0);


while (strbuf_getline(&buf, stdin) != EOF) { while (strbuf_getline(&buf, stdin) != EOF) {

View File

@ -197,7 +197,8 @@ static int traverse_reachable(void)
unsigned int nr = 0; unsigned int nr = 0;
int result = 0; int result = 0;
if (show_progress) if (show_progress)
progress = start_delayed_progress(_("Checking connectivity"), 0); progress = start_delayed_progress(the_repository,
_("Checking connectivity"), 0);
while (pending.nr) { while (pending.nr) {
result |= traverse_one_object(object_array_pop(&pending)); result |= traverse_one_object(object_array_pop(&pending));
display_progress(progress, ++nr); display_progress(progress, ++nr);
@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)
fprintf_ln(stderr, _("Checking object directory")); fprintf_ln(stderr, _("Checking object directory"));


if (show_progress) if (show_progress)
progress = start_progress(_("Checking object directories"), 256); progress = start_progress(the_repository,
_("Checking object directories"), 256);


for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir, for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
&cb_data); &cb_data);
@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)
if (show_progress) { if (show_progress) {
for (struct packed_git *p = get_all_packs(r); p; p = p->next) for (struct packed_git *p = get_all_packs(r); p; p = p->next)
pack_count++; pack_count++;
progress = start_delayed_progress("Verifying reverse pack-indexes", pack_count); progress = start_delayed_progress(the_repository,
"Verifying reverse pack-indexes", pack_count);
pack_count = 0; pack_count = 0;
} }


@ -989,7 +992,8 @@ int cmd_fsck(int argc,
total += p->num_objects; total += p->num_objects;
} }


progress = start_progress(_("Checking objects"), total); progress = start_progress(the_repository,
_("Checking objects"), total);
} }
for (p = get_all_packs(the_repository); p; for (p = get_all_packs(the_repository); p;
p = p->next) { p = p->next) {

View File

@ -282,7 +282,8 @@ static unsigned check_objects(void)
max = get_max_object_index(); max = get_max_object_index();


if (verbose) if (verbose)
progress = start_delayed_progress(_("Checking objects"), max); progress = start_delayed_progress(the_repository,
_("Checking objects"), max);


for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
foreign_nr += check_object(get_indexed_object(i)); foreign_nr += check_object(get_indexed_object(i));
@ -1249,6 +1250,7 @@ static void parse_pack_objects(unsigned char *hash)


if (verbose) if (verbose)
progress = start_progress( progress = start_progress(
the_repository,
progress_title ? progress_title : progress_title ? progress_title :
from_stdin ? _("Receiving objects") : _("Indexing objects"), from_stdin ? _("Receiving objects") : _("Indexing objects"),
nr_objects); nr_objects);
@ -1329,7 +1331,8 @@ static void resolve_deltas(struct pack_idx_option *opts)
QSORT(ref_deltas, nr_ref_deltas, compare_ref_delta_entry); QSORT(ref_deltas, nr_ref_deltas, compare_ref_delta_entry);


if (verbose || show_resolving_progress) if (verbose || show_resolving_progress)
progress = start_progress(_("Resolving deltas"), progress = start_progress(the_repository,
_("Resolving deltas"),
nr_ref_deltas + nr_ofs_deltas); nr_ref_deltas + nr_ofs_deltas);


nr_dispatched = 0; nr_dispatched = 0;

View File

@ -2495,7 +2495,8 @@ int cmd_format_patch(int argc,
rev.add_signoff = cfg.do_signoff; rev.add_signoff = cfg.do_signoff;


if (show_progress) if (show_progress)
progress = start_delayed_progress(_("Generating patches"), total); progress = start_delayed_progress(the_repository,
_("Generating patches"), total);
while (0 <= --nr) { while (0 <= --nr) {
int shown; int shown;
display_progress(progress, total - nr); display_progress(progress, total - nr);

View File

@ -1264,7 +1264,8 @@ static void write_pack_file(void)
struct object_entry **write_order; struct object_entry **write_order;


if (progress > pack_to_stdout) if (progress > pack_to_stdout)
progress_state = start_progress(_("Writing objects"), nr_result); progress_state = start_progress(the_repository,
_("Writing objects"), nr_result);
ALLOC_ARRAY(written_list, to_pack.nr_objects); ALLOC_ARRAY(written_list, to_pack.nr_objects);
write_order = compute_write_order(); write_order = compute_write_order();


@ -2400,7 +2401,8 @@ static void get_object_details(void)
struct object_entry **sorted_by_offset; struct object_entry **sorted_by_offset;


if (progress) if (progress)
progress_state = start_progress(_("Counting objects"), progress_state = start_progress(the_repository,
_("Counting objects"),
to_pack.nr_objects); to_pack.nr_objects);


CALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects); CALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects);
@ -3220,7 +3222,8 @@ static void prepare_pack(int window, int depth)
unsigned nr_done = 0; unsigned nr_done = 0;


if (progress) if (progress)
progress_state = start_progress(_("Compressing objects"), progress_state = start_progress(the_repository,
_("Compressing objects"),
nr_deltas); nr_deltas);
QSORT(delta_list, n, type_size_sort); QSORT(delta_list, n, type_size_sort);
ll_find_deltas(delta_list, n, window+1, depth, &nr_done); ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
@ -3648,7 +3651,8 @@ static void add_objects_in_unpacked_packs(void);
static void enumerate_cruft_objects(void) static void enumerate_cruft_objects(void)
{ {
if (progress) if (progress)
progress_state = start_progress(_("Enumerating cruft objects"), 0); progress_state = start_progress(the_repository,
_("Enumerating cruft objects"), 0);


add_objects_in_unpacked_packs(); add_objects_in_unpacked_packs();
add_unreachable_loose_objects(); add_unreachable_loose_objects();
@ -3674,7 +3678,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
revs.ignore_missing_links = 1; revs.ignore_missing_links = 1;


if (progress) if (progress)
progress_state = start_progress(_("Enumerating cruft objects"), 0); progress_state = start_progress(the_repository,
_("Enumerating cruft objects"), 0);
ret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration, ret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration,
set_cruft_mtime, 1); set_cruft_mtime, 1);
stop_progress(&progress_state); stop_progress(&progress_state);
@ -3693,7 +3698,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
if (prepare_revision_walk(&revs)) if (prepare_revision_walk(&revs))
die(_("revision walk setup failed")); die(_("revision walk setup failed"));
if (progress) if (progress)
progress_state = start_progress(_("Traversing cruft objects"), 0); progress_state = start_progress(the_repository,
_("Traversing cruft objects"), 0);
nr_seen = 0; nr_seen = 0;
traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL); traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);


@ -4625,7 +4631,8 @@ int cmd_pack_objects(int argc,
prepare_packing_data(the_repository, &to_pack); prepare_packing_data(the_repository, &to_pack);


if (progress && !cruft) if (progress && !cruft)
progress_state = start_progress(_("Enumerating objects"), 0); progress_state = start_progress(the_repository,
_("Enumerating objects"), 0);
if (stdin_packs) { if (stdin_packs) {
/* avoids adding objects in excluded packs */ /* avoids adding objects in excluded packs */
ignore_packed_keep_in_core = 1; ignore_packed_keep_in_core = 1;

View File

@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)
return; return;


if (show_progress) if (show_progress)
progress = start_delayed_progress(_("Checking connectivity"), 0); progress = start_delayed_progress(the_repository,
_("Checking connectivity"), 0);
mark_reachable_objects(revs, 1, expire, progress); mark_reachable_objects(revs, 1, expire, progress);
stop_progress(&progress); stop_progress(&progress);
initialized = 1; initialized = 1;

View File

@ -820,7 +820,8 @@ static int mv(int argc, const char **argv, const char *prefix,
* Count symrefs twice, since "renaming" them is done by * Count symrefs twice, since "renaming" them is done by
* deleting and recreating them in two separate passes. * deleting and recreating them in two separate passes.
*/ */
progress = start_progress(_("Renaming remote references"), progress = start_progress(the_repository,
_("Renaming remote references"),
rename.remote_branches->nr + rename.symrefs_nr); rename.remote_branches->nr + rename.symrefs_nr);
} }
for (i = 0; i < remote_branches.nr; i++) { for (i = 0; i < remote_branches.nr; i++) {

View File

@ -735,7 +735,8 @@ int cmd_rev_list(int argc,
revs.limited = 1; revs.limited = 1;


if (show_progress) if (show_progress)
progress = start_delayed_progress(show_progress, 0); progress = start_delayed_progress(the_repository,
show_progress, 0);


if (use_bitmap_index) { if (use_bitmap_index) {
if (!try_bitmap_count(&revs, filter_provided_objects)) if (!try_bitmap_count(&revs, filter_provided_objects))

View File

@ -590,7 +590,8 @@ static void unpack_all(void)
use(sizeof(struct pack_header)); use(sizeof(struct pack_header));


if (!quiet) if (!quiet)
progress = start_progress(_("Unpacking objects"), nr_objects); progress = start_progress(the_repository,
_("Unpacking objects"), nr_objects);
CALLOC_ARRAY(obj_list, nr_objects); CALLOC_ARRAY(obj_list, nr_objects);
begin_odb_transaction(); begin_odb_transaction();
for (i = 0; i < nr_objects; i++) { for (i = 0; i < nr_objects; i++) {

View File

@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)


if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Loading known commits in commit graph"), _("Loading known commits in commit graph"),
ctx->oids.nr); ctx->oids.nr);
for (i = 0; i < ctx->oids.nr; i++) { for (i = 0; i < ctx->oids.nr; i++) {
@ -1551,6 +1552,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
*/ */
if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Expanding reachable commits in commit graph"), _("Expanding reachable commits in commit graph"),
0); 0);
for (i = 0; i < ctx->oids.nr; i++) { for (i = 0; i < ctx->oids.nr; i++) {
@ -1571,6 +1573,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)


if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Clearing commit marks in commit graph"), _("Clearing commit marks in commit graph"),
ctx->oids.nr); ctx->oids.nr);
for (i = 0; i < ctx->oids.nr; i++) { for (i = 0; i < ctx->oids.nr; i++) {
@ -1688,6 +1691,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)
if (ctx->report_progress) if (ctx->report_progress)
info.progress = ctx->progress info.progress = ctx->progress
= start_delayed_progress( = start_delayed_progress(
the_repository,
_("Computing commit graph topological levels"), _("Computing commit graph topological levels"),
ctx->commits.nr); ctx->commits.nr);


@ -1722,6 +1726,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
if (ctx->report_progress) if (ctx->report_progress)
info.progress = ctx->progress info.progress = ctx->progress
= start_delayed_progress( = start_delayed_progress(
the_repository,
_("Computing commit graph generation numbers"), _("Computing commit graph generation numbers"),
ctx->commits.nr); ctx->commits.nr);


@ -1798,6 +1803,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)


if (ctx->report_progress) if (ctx->report_progress)
progress = start_delayed_progress( progress = start_delayed_progress(
the_repository,
_("Computing commit changed paths Bloom filters"), _("Computing commit changed paths Bloom filters"),
ctx->commits.nr); ctx->commits.nr);


@ -1877,6 +1883,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
data.commits = &commits; data.commits = &commits;
if (flags & COMMIT_GRAPH_WRITE_PROGRESS) if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
data.progress = start_delayed_progress( data.progress = start_delayed_progress(
the_repository,
_("Collecting referenced commits"), 0); _("Collecting referenced commits"), 0);


refs_for_each_ref(get_main_ref_store(the_repository), add_ref_to_set, refs_for_each_ref(get_main_ref_store(the_repository), add_ref_to_set,
@ -1908,7 +1915,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
"Finding commits for commit graph in %"PRIuMAX" packs", "Finding commits for commit graph in %"PRIuMAX" packs",
pack_indexes->nr), pack_indexes->nr),
(uintmax_t)pack_indexes->nr); (uintmax_t)pack_indexes->nr);
ctx->progress = start_delayed_progress(progress_title.buf, 0); ctx->progress = start_delayed_progress(the_repository,
progress_title.buf, 0);
ctx->progress_done = 0; ctx->progress_done = 0;
} }
for (i = 0; i < pack_indexes->nr; i++) { for (i = 0; i < pack_indexes->nr; i++) {
@ -1959,6 +1967,7 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
{ {
if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Finding commits for commit graph among packed objects"), _("Finding commits for commit graph among packed objects"),
ctx->approx_nr_objects); ctx->approx_nr_objects);
for_each_packed_object(ctx->r, add_packed_commits, ctx, for_each_packed_object(ctx->r, add_packed_commits, ctx,
@ -1977,6 +1986,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
ctx->num_extra_edges = 0; ctx->num_extra_edges = 0;
if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Finding extra edges in commit graph"), _("Finding extra edges in commit graph"),
ctx->oids.nr); ctx->oids.nr);
oid_array_sort(&ctx->oids); oid_array_sort(&ctx->oids);
@ -2136,6 +2146,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
get_num_chunks(cf)), get_num_chunks(cf)),
get_num_chunks(cf)); get_num_chunks(cf));
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
progress_title.buf, progress_title.buf,
st_mult(get_num_chunks(cf), ctx->commits.nr)); st_mult(get_num_chunks(cf), ctx->commits.nr));
} }
@ -2348,6 +2359,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)


if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
the_repository,
_("Scanning merged commits"), _("Scanning merged commits"),
ctx->commits.nr); ctx->commits.nr);


@ -2392,7 +2404,8 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx)
current_graph_number--; current_graph_number--;


if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress(_("Merging commit-graph"), 0); ctx->progress = start_delayed_progress(the_repository,
_("Merging commit-graph"), 0);


merge_commit_graph(ctx, g); merge_commit_graph(ctx, g);
stop_progress(&ctx->progress); stop_progress(&ctx->progress);
@ -2874,7 +2887,8 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW)) if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))
total += g->num_commits_in_base; total += g->num_commits_in_base;


progress = start_progress(_("Verifying commits in commit graph"), progress = start_progress(the_repository,
_("Verifying commits in commit graph"),
total); total);
} }



View File

@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,
QSORT(todo, nr, tree_depth_compare); QSORT(todo, nr, tree_depth_compare);


if (progress) if (progress)
progress_state = start_progress(_("Propagating island marks"), nr); progress_state = start_progress(the_repository,
_("Propagating island marks"), nr);


for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct object_entry *ent = todo[i].entry; struct object_entry *ent = todo[i].entry;

View File

@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
trace2_region_enter("diff", "inexact renames", options->repo); trace2_region_enter("diff", "inexact renames", options->repo);
if (options->show_rename_progress) { if (options->show_rename_progress) {
progress = start_delayed_progress( progress = start_delayed_progress(
the_repository,
_("Performing inexact rename detection"), _("Performing inexact rename detection"),
(uint64_t)num_destinations * (uint64_t)num_sources); (uint64_t)num_destinations * (uint64_t)num_sources);
} }

View File

@ -188,7 +188,9 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)


dco->state = CE_RETRY; dco->state = CE_RETRY;
if (show_progress) if (show_progress)
progress = start_delayed_progress(_("Filtering content"), dco->paths.nr); progress = start_delayed_progress(the_repository,
_("Filtering content"),
dco->paths.nr);
while (dco->filters.nr > 0) { while (dco->filters.nr > 0) {
for_each_string_list_item(filter, &dco->filters) { for_each_string_list_item(filter, &dco->filters) {
struct string_list available_paths = STRING_LIST_INIT_DUP; struct string_list available_paths = STRING_LIST_INIT_DUP;

View File

@ -1131,7 +1131,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,


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


@ -1539,7 +1540,9 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
CALLOC_ARRAY(count, m->num_packs); CALLOC_ARRAY(count, m->num_packs);


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


if (flags & MIDX_PROGRESS) if (flags & MIDX_PROGRESS)
progress = start_delayed_progress(_("Finding and deleting unreferenced packfiles"), progress = start_delayed_progress(
r,
_("Finding and deleting unreferenced packfiles"),
m->num_packs); m->num_packs);
for (i = 0; i < m->num_packs; i++) { for (i = 0; i < m->num_packs; i++) {
char *pack_name; char *pack_name;

13
midx.c
View File

@ -907,7 +907,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
midx_report(_("incorrect checksum")); midx_report(_("incorrect checksum"));


if (flags & MIDX_PROGRESS) if (flags & MIDX_PROGRESS)
progress = start_delayed_progress(_("Looking for referenced packfiles"), progress = start_delayed_progress(r,
_("Looking for referenced packfiles"),
m->num_packs + m->num_packs_in_base); m->num_packs + m->num_packs_in_base);
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) { for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
if (prepare_midx_pack(r, m, i)) if (prepare_midx_pack(r, m, i))
@ -927,7 +928,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
} }


if (flags & MIDX_PROGRESS) if (flags & MIDX_PROGRESS)
progress = start_sparse_progress(_("Verifying OID order in multi-pack-index"), progress = start_sparse_progress(r,
_("Verifying OID order in multi-pack-index"),
m->num_objects - 1); m->num_objects - 1);


for (curr = m; curr; curr = curr->base_midx) { for (curr = m; curr; curr = curr->base_midx) {
@ -959,14 +961,17 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
} }


if (flags & MIDX_PROGRESS) if (flags & MIDX_PROGRESS)
progress = start_sparse_progress(_("Sorting objects by packfile"), progress = start_sparse_progress(r,
_("Sorting objects by packfile"),
m->num_objects); m->num_objects);
display_progress(progress, 0); /* TODO: Measure QSORT() progress */ display_progress(progress, 0); /* TODO: Measure QSORT() progress */
QSORT(pairs, m->num_objects, compare_pair_pos_vs_id); QSORT(pairs, m->num_objects, compare_pair_pos_vs_id);
stop_progress(&progress); stop_progress(&progress);


if (flags & MIDX_PROGRESS) if (flags & MIDX_PROGRESS)
progress = start_sparse_progress(_("Verifying object offsets"), m->num_objects); progress = start_sparse_progress(r,
_("Verifying object offsets"),
m->num_objects);
for (i = 0; i < m->num_objects + m->num_objects_in_base; i++) { for (i = 0; i < m->num_objects + m->num_objects_in_base; i++) {
struct object_id oid; struct object_id oid;
struct pack_entry e; struct pack_entry e;

View File

@ -590,7 +590,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)
int closed = 1; /* until proven otherwise */ int closed = 1; /* until proven otherwise */


if (writer->show_progress) if (writer->show_progress)
writer->progress = start_progress("Building bitmaps", writer->progress = start_progress(the_repository,
"Building bitmaps",
writer->selected_nr); writer->selected_nr);
trace2_region_enter("pack-bitmap-write", "building_bitmaps_total", trace2_region_enter("pack-bitmap-write", "building_bitmaps_total",
the_repository); the_repository);
@ -710,7 +711,8 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,
} }


if (writer->show_progress) if (writer->show_progress)
writer->progress = start_progress("Selecting bitmap commits", 0); writer->progress = start_progress(the_repository,
"Selecting bitmap commits", 0);


for (;;) { for (;;) {
struct commit *chosen = NULL; struct commit *chosen = NULL;

View File

@ -2578,7 +2578,9 @@ void test_bitmap_walk(struct rev_info *revs)
tdata.trees = ewah_to_bitmap(bitmap_git->trees); tdata.trees = ewah_to_bitmap(bitmap_git->trees);
tdata.blobs = ewah_to_bitmap(bitmap_git->blobs); tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);
tdata.tags = ewah_to_bitmap(bitmap_git->tags); tdata.tags = ewah_to_bitmap(bitmap_git->tags);
tdata.prg = start_progress("Verifying bitmap entries", result_popcnt); tdata.prg = start_progress(revs->repo,
"Verifying bitmap entries",
result_popcnt);
tdata.seen = 0; tdata.seen = 0;


traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata); traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);

View File

@ -132,7 +132,9 @@ void preload_index(struct index_state *index,


memset(&pd, 0, sizeof(pd)); memset(&pd, 0, sizeof(pd));
if (refresh_flags & REFRESH_PROGRESS && isatty(2)) { if (refresh_flags & REFRESH_PROGRESS && isatty(2)) {
pd.progress = start_delayed_progress(_("Refreshing index"), index->cache_nr); pd.progress = start_delayed_progress(the_repository,
_("Refreshing index"),
index->cache_nr);
pthread_mutex_init(&pd.mutex, NULL); pthread_mutex_init(&pd.mutex, NULL);
} }



View File

@ -9,7 +9,6 @@
*/ */


#define GIT_TEST_PROGRESS_ONLY #define GIT_TEST_PROGRESS_ONLY
#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS #define DISABLE_SIGN_COMPARE_WARNINGS


#include "git-compat-util.h" #include "git-compat-util.h"
@ -37,6 +36,7 @@ struct throughput {
}; };


struct progress { struct progress {
struct repository *repo;
const char *title; const char *title;
uint64_t last_value; uint64_t last_value;
uint64_t total; uint64_t total;
@ -254,10 +254,12 @@ void display_progress(struct progress *progress, uint64_t n)
display(progress, n, NULL); display(progress, n, NULL);
} }


static struct progress *start_progress_delay(const char *title, uint64_t total, static struct progress *start_progress_delay(struct repository *r,
const char *title, uint64_t total,
unsigned delay, unsigned sparse) unsigned delay, unsigned sparse)
{ {
struct progress *progress = xmalloc(sizeof(*progress)); struct progress *progress = xmalloc(sizeof(*progress));
progress->repo = r;
progress->title = title; progress->title = title;
progress->total = total; progress->total = total;
progress->last_value = -1; progress->last_value = -1;
@ -270,7 +272,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
progress->title_len = utf8_strwidth(title); progress->title_len = utf8_strwidth(title);
progress->split = 0; progress->split = 0;
set_progress_signal(); set_progress_signal();
trace2_region_enter("progress", title, the_repository); trace2_region_enter("progress", title, r);
return progress; return progress;
} }


@ -284,14 +286,16 @@ static int get_default_delay(void)
return delay_in_secs; return delay_in_secs;
} }


struct progress *start_delayed_progress(const char *title, uint64_t total) struct progress *start_delayed_progress(struct repository *r,
const char *title, uint64_t total)
{ {
return start_progress_delay(title, total, get_default_delay(), 0); return start_progress_delay(r, title, total, get_default_delay(), 0);
} }


struct progress *start_progress(const char *title, uint64_t total) struct progress *start_progress(struct repository *r,
const char *title, uint64_t total)
{ {
return start_progress_delay(title, total, 0, 0); return start_progress_delay(r, title, total, 0, 0);
} }


/* /*
@ -303,15 +307,17 @@ struct progress *start_progress(const char *title, uint64_t total)
* When "sparse" is set, stop_progress() will automatically force the done * When "sparse" is set, stop_progress() will automatically force the done
* message to show 100%. * message to show 100%.
*/ */
struct progress *start_sparse_progress(const char *title, uint64_t total) struct progress *start_sparse_progress(struct repository *r,
const char *title, uint64_t total)
{ {
return start_progress_delay(title, total, 0, 1); return start_progress_delay(r, title, total, 0, 1);
} }


struct progress *start_delayed_sparse_progress(const char *title, struct progress *start_delayed_sparse_progress(struct repository *r,
const char *title,
uint64_t total) uint64_t total)
{ {
return start_progress_delay(title, total, get_default_delay(), 1); return start_progress_delay(r, title, total, get_default_delay(), 1);
} }


static void finish_if_sparse(struct progress *progress) static void finish_if_sparse(struct progress *progress)
@ -341,14 +347,14 @@ static void force_last_update(struct progress *progress, const char *msg)


static void log_trace2(struct progress *progress) static void log_trace2(struct progress *progress)
{ {
trace2_data_intmax("progress", the_repository, "total_objects", trace2_data_intmax("progress", progress->repo, "total_objects",
progress->total); progress->total);


if (progress->throughput) if (progress->throughput)
trace2_data_intmax("progress", the_repository, "total_bytes", trace2_data_intmax("progress", progress->repo, "total_bytes",
progress->throughput->curr_total); progress->throughput->curr_total);


trace2_region_leave("progress", progress->title, the_repository); trace2_region_leave("progress", progress->title, progress->repo);
} }


void stop_progress_msg(struct progress **p_progress, const char *msg) void stop_progress_msg(struct progress **p_progress, const char *msg)

View File

@ -3,6 +3,7 @@
#include "gettext.h" #include "gettext.h"


struct progress; struct progress;
struct repository;


#ifdef GIT_TEST_PROGRESS_ONLY #ifdef GIT_TEST_PROGRESS_ONLY


@ -14,10 +15,14 @@ void progress_test_force_update(void);


void display_throughput(struct progress *progress, uint64_t total); void display_throughput(struct progress *progress, uint64_t total);
void display_progress(struct progress *progress, uint64_t n); void display_progress(struct progress *progress, uint64_t n);
struct progress *start_progress(const char *title, uint64_t total); struct progress *start_progress(struct repository *r,
struct progress *start_sparse_progress(const char *title, uint64_t total); const char *title, uint64_t total);
struct progress *start_delayed_progress(const char *title, uint64_t total); struct progress *start_sparse_progress(struct repository *r,
struct progress *start_delayed_sparse_progress(const char *title, const char *title, uint64_t total);
struct progress *start_delayed_progress(struct repository *r,
const char *title, uint64_t total);
struct progress *start_delayed_sparse_progress(struct repository *r,
const char *title,
uint64_t total); uint64_t total);
void stop_progress_msg(struct progress **p_progress, const char *msg); void stop_progress_msg(struct progress **p_progress, const char *msg);
static inline void stop_progress(struct progress **p_progress) static inline void stop_progress(struct progress **p_progress)

View File

@ -37,7 +37,8 @@ static int prune_object(const struct object_id *oid, const char *path,
void prune_packed_objects(int opts) void prune_packed_objects(int opts)
{ {
if (opts & PRUNE_PACKED_VERBOSE) if (opts & PRUNE_PACKED_VERBOSE)
progress = start_delayed_progress(_("Removing duplicate objects"), 256); progress = start_delayed_progress(the_repository,
_("Removing duplicate objects"), 256);


for_each_loose_file_in_objdir(repo_get_object_directory(the_repository), for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
prune_object, NULL, prune_subdir, &opts); prune_object, NULL, prune_subdir, &opts);

View File

@ -459,7 +459,8 @@ void select_pseudo_merges(struct bitmap_writer *writer)
return; return;


if (writer->show_progress) if (writer->show_progress)
progress = start_progress("Selecting pseudo-merge commits", progress = start_progress(the_repository,
"Selecting pseudo-merge commits",
writer->pseudo_merge_groups.nr); writer->pseudo_merge_groups.nr);


refs_for_each_ref(get_main_ref_store(the_repository), refs_for_each_ref(get_main_ref_store(the_repository),

View File

@ -1523,7 +1523,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
int t2_sum_scan = 0; int t2_sum_scan = 0;


if (flags & REFRESH_PROGRESS && isatty(2)) if (flags & REFRESH_PROGRESS && isatty(2))
progress = start_delayed_progress(_("Refresh index"), progress = start_delayed_progress(the_repository,
_("Refresh index"),
istate->cache_nr); istate->cache_nr);


trace_performance_enter(); trace_performance_enter();

View File

@ -17,10 +17,14 @@
* *
* See 't0500-progress-display.sh' for examples. * See 't0500-progress-display.sh' for examples.
*/ */

#define USE_THE_REPOSITORY_VARIABLE
#define GIT_TEST_PROGRESS_ONLY #define GIT_TEST_PROGRESS_ONLY

#include "test-tool.h" #include "test-tool.h"
#include "parse-options.h" #include "parse-options.h"
#include "progress.h" #include "progress.h"
#include "repository.h"
#include "strbuf.h" #include "strbuf.h"
#include "string-list.h" #include "string-list.h"


@ -64,7 +68,7 @@ int cmd__progress(int argc, const char **argv)
else else
die("invalid input: '%s'", line.buf); die("invalid input: '%s'", line.buf);


progress = start_progress(title, total); progress = start_progress(the_repository, title, total);
} else if (skip_prefix(line.buf, "progress ", (const char **) &end)) { } else if (skip_prefix(line.buf, "progress ", (const char **) &end)) {
uint64_t item_count = strtoull(end, &end, 10); uint64_t item_count = strtoull(end, &end, 10);
if (*end != '\0') if (*end != '\0')

View File

@ -372,7 +372,8 @@ static struct progress *get_progress(struct unpack_trees_options *o,
total++; total++;
} }


return start_delayed_progress(_("Updating files"), total); return start_delayed_progress(the_repository,
_("Updating files"), total);
} }


static void setup_collided_checkout_detection(struct checkout *state, static void setup_collided_checkout_detection(struct checkout *state,
@ -1773,6 +1774,7 @@ static int clear_ce_flags(struct index_state *istate,
strbuf_reset(&prefix); strbuf_reset(&prefix);
if (show_progress) if (show_progress)
istate->progress = start_delayed_progress( istate->progress = start_delayed_progress(
the_repository,
_("Updating index flags"), _("Updating index flags"),
istate->cache_nr); istate->cache_nr);



View File

@ -172,7 +172,8 @@ static int loop(struct walker *walker)
uint64_t nr = 0; uint64_t nr = 0;


if (walker->get_progress) if (walker->get_progress)
progress = start_delayed_progress(_("Fetching objects"), 0); progress = start_delayed_progress(the_repository,
_("Fetching objects"), 0);


while (process_queue) { while (process_queue) {
struct object *obj = process_queue->item; struct object *obj = process_queue->item;