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>

Patrick Steinhardt committed Dec 17, 2024 at 07:43 UTC 1f7e6478dcd9e7462c70a5784ae0d41ab25ced11
27 files changed +136 -59
builtin/blame.c
+3 -1
@@ -1193,7 +1193,9 @@ parse_done:
1193 sb.found_guilty_entry = &found_guilty_entry;
1194 sb.found_guilty_entry_data = &pi;
1195 if (show_progress)
1196 - pi.progress = start_delayed_progress(_("Blaming lines"), num_lines);
1196 + pi.progress = start_delayed_progress(the_repository,
1197 + _("Blaming lines"),
1198 + num_lines);
1199
1200 assign_blame(&sb, opt);
1201
builtin/commit-graph.c
+1
@@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
305 oidset_init(&commits, 0);
306 if (opts.progress)
307 progress = start_delayed_progress(
308 + the_repository,
309 _("Collecting commits from input"), 0);
310
311 while (strbuf_getline(&buf, stdin) != EOF) {
builtin/fsck.c
+8 -4
@@ -197,7 +197,8 @@ static int traverse_reachable(void)
197 unsigned int nr = 0;
198 int result = 0;
199 if (show_progress)
200 - progress = start_delayed_progress(_("Checking connectivity"), 0);
200 + progress = start_delayed_progress(the_repository,
201 + _("Checking connectivity"), 0);
202 while (pending.nr) {
203 result |= traverse_one_object(object_array_pop(&pending));
204 display_progress(progress, ++nr);
@@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)
704 fprintf_ln(stderr, _("Checking object directory"));
705
706 if (show_progress)
706 - progress = start_progress(_("Checking object directories"), 256);
707 + progress = start_progress(the_repository,
708 + _("Checking object directories"), 256);
709
710 for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
711 &cb_data);
@@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)
881 if (show_progress) {
882 for (struct packed_git *p = get_all_packs(r); p; p = p->next)
883 pack_count++;
882 - progress = start_delayed_progress("Verifying reverse pack-indexes", pack_count);
884 + progress = start_delayed_progress(the_repository,
885 + "Verifying reverse pack-indexes", pack_count);
886 pack_count = 0;
887 }
888
@@ -989,7 +992,8 @@ int cmd_fsck(int argc,
992 total += p->num_objects;
993 }
994
992 - progress = start_progress(_("Checking objects"), total);
995 + progress = start_progress(the_repository,
996 + _("Checking objects"), total);
997 }
998 for (p = get_all_packs(the_repository); p;
999 p = p->next) {
builtin/index-pack.c
+5 -2
@@ -282,7 +282,8 @@ static unsigned check_objects(void)
282 max = get_max_object_index();
283
284 if (verbose)
285 - progress = start_delayed_progress(_("Checking objects"), max);
285 + progress = start_delayed_progress(the_repository,
286 + _("Checking objects"), max);
287
288 for (i = 0; i < max; i++) {
289 foreign_nr += check_object(get_indexed_object(i));
@@ -1249,6 +1250,7 @@ static void parse_pack_objects(unsigned char *hash)
1250
1251 if (verbose)
1252 progress = start_progress(
1253 + the_repository,
1254 progress_title ? progress_title :
1255 from_stdin ? _("Receiving objects") : _("Indexing objects"),
1256 nr_objects);
@@ -1329,7 +1331,8 @@ static void resolve_deltas(struct pack_idx_option *opts)
1331 QSORT(ref_deltas, nr_ref_deltas, compare_ref_delta_entry);
1332
1333 if (verbose || show_resolving_progress)
1332 - progress = start_progress(_("Resolving deltas"),
1334 + progress = start_progress(the_repository,
1335 + _("Resolving deltas"),
1336 nr_ref_deltas + nr_ofs_deltas);
1337
1338 nr_dispatched = 0;
builtin/log.c
+2 -1
@@ -2495,7 +2495,8 @@ int cmd_format_patch(int argc,
2495 rev.add_signoff = cfg.do_signoff;
2496
2497 if (show_progress)
2498 - progress = start_delayed_progress(_("Generating patches"), total);
2498 + progress = start_delayed_progress(the_repository,
2499 + _("Generating patches"), total);
2500 while (0 <= --nr) {
2501 int shown;
2502 display_progress(progress, total - nr);
builtin/pack-objects.c
+14 -7
@@ -1264,7 +1264,8 @@ static void write_pack_file(void)
1264 struct object_entry **write_order;
1265
1266 if (progress > pack_to_stdout)
1267 - progress_state = start_progress(_("Writing objects"), nr_result);
1267 + progress_state = start_progress(the_repository,
1268 + _("Writing objects"), nr_result);
1269 ALLOC_ARRAY(written_list, to_pack.nr_objects);
1270 write_order = compute_write_order();
1271
@@ -2400,7 +2401,8 @@ static void get_object_details(void)
2401 struct object_entry **sorted_by_offset;
2402
2403 if (progress)
2403 - progress_state = start_progress(_("Counting objects"),
2404 + progress_state = start_progress(the_repository,
2405 + _("Counting objects"),
2406 to_pack.nr_objects);
2407
2408 CALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects);
@@ -3220,7 +3222,8 @@ static void prepare_pack(int window, int depth)
3222 unsigned nr_done = 0;
3223
3224 if (progress)
3223 - progress_state = start_progress(_("Compressing objects"),
3225 + progress_state = start_progress(the_repository,
3226 + _("Compressing objects"),
3227 nr_deltas);
3228 QSORT(delta_list, n, type_size_sort);
3229 ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
@@ -3648,7 +3651,8 @@ static void add_objects_in_unpacked_packs(void);
3651 static void enumerate_cruft_objects(void)
3652 {
3653 if (progress)
3651 - progress_state = start_progress(_("Enumerating cruft objects"), 0);
3654 + progress_state = start_progress(the_repository,
3655 + _("Enumerating cruft objects"), 0);
3656
3657 add_objects_in_unpacked_packs();
3658 add_unreachable_loose_objects();
@@ -3674,7 +3678,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
3678 revs.ignore_missing_links = 1;
3679
3680 if (progress)
3677 - progress_state = start_progress(_("Enumerating cruft objects"), 0);
3681 + progress_state = start_progress(the_repository,
3682 + _("Enumerating cruft objects"), 0);
3683 ret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration,
3684 set_cruft_mtime, 1);
3685 stop_progress(&progress_state);
@@ -3693,7 +3698,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
3698 if (prepare_revision_walk(&revs))
3699 die(_("revision walk setup failed"));
3700 if (progress)
3696 - progress_state = start_progress(_("Traversing cruft objects"), 0);
3701 + progress_state = start_progress(the_repository,
3702 + _("Traversing cruft objects"), 0);
3703 nr_seen = 0;
3704 traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);
3705
@@ -4625,7 +4631,8 @@ int cmd_pack_objects(int argc,
4631 prepare_packing_data(the_repository, &to_pack);
4632
4633 if (progress && !cruft)
4628 - progress_state = start_progress(_("Enumerating objects"), 0);
4634 + progress_state = start_progress(the_repository,
4635 + _("Enumerating objects"), 0);
4636 if (stdin_packs) {
4637 /* avoids adding objects in excluded packs */
4638 ignore_packed_keep_in_core = 1;
builtin/prune.c
+2 -1
@@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)
64 return;
65
66 if (show_progress)
67 - progress = start_delayed_progress(_("Checking connectivity"), 0);
67 + progress = start_delayed_progress(the_repository,
68 + _("Checking connectivity"), 0);
69 mark_reachable_objects(revs, 1, expire, progress);
70 stop_progress(&progress);
71 initialized = 1;
builtin/remote.c
+2 -1
@@ -820,7 +820,8 @@ static int mv(int argc, const char **argv, const char *prefix,
820 * Count symrefs twice, since "renaming" them is done by
821 * deleting and recreating them in two separate passes.
822 */
823 - progress = start_progress(_("Renaming remote references"),
823 + progress = start_progress(the_repository,
824 + _("Renaming remote references"),
825 rename.remote_branches->nr + rename.symrefs_nr);
826 }
827 for (i = 0; i < remote_branches.nr; i++) {
builtin/rev-list.c
+2 -1
@@ -735,7 +735,8 @@ int cmd_rev_list(int argc,
735 revs.limited = 1;
736
737 if (show_progress)
738 - progress = start_delayed_progress(show_progress, 0);
738 + progress = start_delayed_progress(the_repository,
739 + show_progress, 0);
740
741 if (use_bitmap_index) {
742 if (!try_bitmap_count(&revs, filter_provided_objects))
builtin/unpack-objects.c
+2 -1
@@ -590,7 +590,8 @@ static void unpack_all(void)
590 use(sizeof(struct pack_header));
591
592 if (!quiet)
593 - progress = start_progress(_("Unpacking objects"), nr_objects);
593 + progress = start_progress(the_repository,
594 + _("Unpacking objects"), nr_objects);
595 CALLOC_ARRAY(obj_list, nr_objects);
596 begin_odb_transaction();
597 for (i = 0; i < nr_objects; i++) {
commit-graph.c
+17 -3
@@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
1534
1535 if (ctx->report_progress)
1536 ctx->progress = start_delayed_progress(
1537 + the_repository,
1538 _("Loading known commits in commit graph"),
1539 ctx->oids.nr);
1540 for (i = 0; i < ctx->oids.nr; i++) {
@@ -1551,6 +1552,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
1552 */
1553 if (ctx->report_progress)
1554 ctx->progress = start_delayed_progress(
1555 + the_repository,
1556 _("Expanding reachable commits in commit graph"),
1557 0);
1558 for (i = 0; i < ctx->oids.nr; i++) {
@@ -1571,6 +1573,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
1573
1574 if (ctx->report_progress)
1575 ctx->progress = start_delayed_progress(
1576 + the_repository,
1577 _("Clearing commit marks in commit graph"),
1578 ctx->oids.nr);
1579 for (i = 0; i < ctx->oids.nr; i++) {
@@ -1688,6 +1691,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)
1691 if (ctx->report_progress)
1692 info.progress = ctx->progress
1693 = start_delayed_progress(
1694 + the_repository,
1695 _("Computing commit graph topological levels"),
1696 ctx->commits.nr);
1697
@@ -1722,6 +1726,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
1726 if (ctx->report_progress)
1727 info.progress = ctx->progress
1728 = start_delayed_progress(
1729 + the_repository,
1730 _("Computing commit graph generation numbers"),
1731 ctx->commits.nr);
1732
@@ -1798,6 +1803,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
1803
1804 if (ctx->report_progress)
1805 progress = start_delayed_progress(
1806 + the_repository,
1807 _("Computing commit changed paths Bloom filters"),
1808 ctx->commits.nr);
1809
@@ -1877,6 +1883,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
1883 data.commits = &commits;
1884 if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
1885 data.progress = start_delayed_progress(
1886 + the_repository,
1887 _("Collecting referenced commits"), 0);
1888
1889 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,
1915 "Finding commits for commit graph in %"PRIuMAX" packs",
1916 pack_indexes->nr),
1917 (uintmax_t)pack_indexes->nr);
1911 - ctx->progress = start_delayed_progress(progress_title.buf, 0);
1918 + ctx->progress = start_delayed_progress(the_repository,
1919 + progress_title.buf, 0);
1920 ctx->progress_done = 0;
1921 }
1922 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)
1967 {
1968 if (ctx->report_progress)
1969 ctx->progress = start_delayed_progress(
1970 + the_repository,
1971 _("Finding commits for commit graph among packed objects"),
1972 ctx->approx_nr_objects);
1973 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)
1986 ctx->num_extra_edges = 0;
1987 if (ctx->report_progress)
1988 ctx->progress = start_delayed_progress(
1989 + the_repository,
1990 _("Finding extra edges in commit graph"),
1991 ctx->oids.nr);
1992 oid_array_sort(&ctx->oids);
@@ -2136,6 +2146,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
2146 get_num_chunks(cf)),
2147 get_num_chunks(cf));
2148 ctx->progress = start_delayed_progress(
2149 + the_repository,
2150 progress_title.buf,
2151 st_mult(get_num_chunks(cf), ctx->commits.nr));
2152 }
@@ -2348,6 +2359,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
2359
2360 if (ctx->report_progress)
2361 ctx->progress = start_delayed_progress(
2362 + the_repository,
2363 _("Scanning merged commits"),
2364 ctx->commits.nr);
2365
@@ -2392,7 +2404,8 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx)
2404 current_graph_number--;
2405
2406 if (ctx->report_progress)
2395 - ctx->progress = start_delayed_progress(_("Merging commit-graph"), 0);
2407 + ctx->progress = start_delayed_progress(the_repository,
2408 + _("Merging commit-graph"), 0);
2409
2410 merge_commit_graph(ctx, g);
2411 stop_progress(&ctx->progress);
@@ -2874,7 +2887,8 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2887 if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))
2888 total += g->num_commits_in_base;
2889
2877 - progress = start_progress(_("Verifying commits in commit graph"),
2890 + progress = start_progress(the_repository,
2891 + _("Verifying commits in commit graph"),
2892 total);
2893 }
2894
delta-islands.c
+2 -1
@@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,
267 QSORT(todo, nr, tree_depth_compare);
268
269 if (progress)
270 - progress_state = start_progress(_("Propagating island marks"), nr);
270 + progress_state = start_progress(the_repository,
271 + _("Propagating island marks"), nr);
272
273 for (i = 0; i < nr; i++) {
274 struct object_entry *ent = todo[i].entry;
diffcore-rename.c
+1
@@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
1567 trace2_region_enter("diff", "inexact renames", options->repo);
1568 if (options->show_rename_progress) {
1569 progress = start_delayed_progress(
1570 + the_repository,
1571 _("Performing inexact rename detection"),
1572 (uint64_t)num_destinations * (uint64_t)num_sources);
1573 }
entry.c
+3 -1
@@ -188,7 +188,9 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
188
189 dco->state = CE_RETRY;
190 if (show_progress)
191 - progress = start_delayed_progress(_("Filtering content"), dco->paths.nr);
191 + progress = start_delayed_progress(the_repository,
192 + _("Filtering content"),
193 + dco->paths.nr);
194 while (dco->filters.nr > 0) {
195 for_each_string_list_item(filter, &dco->filters) {
196 struct string_list available_paths = STRING_LIST_INIT_DUP;
midx-write.c
+8 -3
@@ -1131,7 +1131,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1131
1132 ctx.pack_paths_checked = 0;
1133 if (flags & MIDX_PROGRESS)
1134 - ctx.progress = start_delayed_progress(_("Adding packfiles to multi-pack-index"), 0);
1134 + ctx.progress = start_delayed_progress(r,
1135 + _("Adding packfiles to multi-pack-index"), 0);
1136 else
1137 ctx.progress = NULL;
1138
@@ -1539,7 +1540,9 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1540 CALLOC_ARRAY(count, m->num_packs);
1541
1542 if (flags & MIDX_PROGRESS)
1542 - progress = start_delayed_progress(_("Counting referenced objects"),
1543 + progress = start_delayed_progress(
1544 + r,
1545 + _("Counting referenced objects"),
1546 m->num_objects);
1547 for (i = 0; i < m->num_objects; i++) {
1548 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
1552 stop_progress(&progress);
1553
1554 if (flags & MIDX_PROGRESS)
1552 - progress = start_delayed_progress(_("Finding and deleting unreferenced packfiles"),
1555 + progress = start_delayed_progress(
1556 + r,
1557 + _("Finding and deleting unreferenced packfiles"),
1558 m->num_packs);
1559 for (i = 0; i < m->num_packs; i++) {
1560 char *pack_name;
midx.c
+9 -4
@@ -907,7 +907,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
907 midx_report(_("incorrect checksum"));
908
909 if (flags & MIDX_PROGRESS)
910 - progress = start_delayed_progress(_("Looking for referenced packfiles"),
910 + progress = start_delayed_progress(r,
911 + _("Looking for referenced packfiles"),
912 m->num_packs + m->num_packs_in_base);
913 for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
914 if (prepare_midx_pack(r, m, i))
@@ -927,7 +928,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
928 }
929
930 if (flags & MIDX_PROGRESS)
930 - progress = start_sparse_progress(_("Verifying OID order in multi-pack-index"),
931 + progress = start_sparse_progress(r,
932 + _("Verifying OID order in multi-pack-index"),
933 m->num_objects - 1);
934
935 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
961 }
962
963 if (flags & MIDX_PROGRESS)
962 - progress = start_sparse_progress(_("Sorting objects by packfile"),
964 + progress = start_sparse_progress(r,
965 + _("Sorting objects by packfile"),
966 m->num_objects);
967 display_progress(progress, 0); /* TODO: Measure QSORT() progress */
968 QSORT(pairs, m->num_objects, compare_pair_pos_vs_id);
969 stop_progress(&progress);
970
971 if (flags & MIDX_PROGRESS)
969 - progress = start_sparse_progress(_("Verifying object offsets"), m->num_objects);
972 + progress = start_sparse_progress(r,
973 + _("Verifying object offsets"),
974 + m->num_objects);
975 for (i = 0; i < m->num_objects + m->num_objects_in_base; i++) {
976 struct object_id oid;
977 struct pack_entry e;
pack-bitmap-write.c
+4 -2
@@ -590,7 +590,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)
590 int closed = 1; /* until proven otherwise */
591
592 if (writer->show_progress)
593 - writer->progress = start_progress("Building bitmaps",
593 + writer->progress = start_progress(the_repository,
594 + "Building bitmaps",
595 writer->selected_nr);
596 trace2_region_enter("pack-bitmap-write", "building_bitmaps_total",
597 the_repository);
@@ -710,7 +711,8 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,
711 }
712
713 if (writer->show_progress)
713 - writer->progress = start_progress("Selecting bitmap commits", 0);
714 + writer->progress = start_progress(the_repository,
715 + "Selecting bitmap commits", 0);
716
717 for (;;) {
718 struct commit *chosen = NULL;
pack-bitmap.c
+3 -1
@@ -2578,7 +2578,9 @@ void test_bitmap_walk(struct rev_info *revs)
2578 tdata.trees = ewah_to_bitmap(bitmap_git->trees);
2579 tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);
2580 tdata.tags = ewah_to_bitmap(bitmap_git->tags);
2581 - tdata.prg = start_progress("Verifying bitmap entries", result_popcnt);
2581 + tdata.prg = start_progress(revs->repo,
2582 + "Verifying bitmap entries",
2583 + result_popcnt);
2584 tdata.seen = 0;
2585
2586 traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);
preload-index.c
+3 -1
@@ -132,7 +132,9 @@ void preload_index(struct index_state *index,
132
133 memset(&pd, 0, sizeof(pd));
134 if (refresh_flags & REFRESH_PROGRESS && isatty(2)) {
135 - pd.progress = start_delayed_progress(_("Refreshing index"), index->cache_nr);
135 + pd.progress = start_delayed_progress(the_repository,
136 + _("Refreshing index"),
137 + index->cache_nr);
138 pthread_mutex_init(&pd.mutex, NULL);
139 }
140
progress.c
+20 -14
@@ -9,7 +9,6 @@
9 */
10
11 #define GIT_TEST_PROGRESS_ONLY
12 -#define USE_THE_REPOSITORY_VARIABLE
12 #define DISABLE_SIGN_COMPARE_WARNINGS
13
14 #include "git-compat-util.h"
@@ -37,6 +36,7 @@ struct throughput {
36 };
37
38 struct progress {
39 + struct repository *repo;
40 const char *title;
41 uint64_t last_value;
42 uint64_t total;
@@ -254,10 +254,12 @@ void display_progress(struct progress *progress, uint64_t n)
254 display(progress, n, NULL);
255 }
256
257 -static struct progress *start_progress_delay(const char *title, uint64_t total,
257 +static struct progress *start_progress_delay(struct repository *r,
258 + const char *title, uint64_t total,
259 unsigned delay, unsigned sparse)
260 {
261 struct progress *progress = xmalloc(sizeof(*progress));
262 + progress->repo = r;
263 progress->title = title;
264 progress->total = total;
265 progress->last_value = -1;
@@ -270,7 +272,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
272 progress->title_len = utf8_strwidth(title);
273 progress->split = 0;
274 set_progress_signal();
273 - trace2_region_enter("progress", title, the_repository);
275 + trace2_region_enter("progress", title, r);
276 return progress;
277 }
278
@@ -284,14 +286,16 @@ static int get_default_delay(void)
286 return delay_in_secs;
287 }
288
287 -struct progress *start_delayed_progress(const char *title, uint64_t total)
289 +struct progress *start_delayed_progress(struct repository *r,
290 + const char *title, uint64_t total)
291 {
289 - return start_progress_delay(title, total, get_default_delay(), 0);
292 + return start_progress_delay(r, title, total, get_default_delay(), 0);
293 }
294
292 -struct progress *start_progress(const char *title, uint64_t total)
295 +struct progress *start_progress(struct repository *r,
296 + const char *title, uint64_t total)
297 {
294 - return start_progress_delay(title, total, 0, 0);
298 + return start_progress_delay(r, title, total, 0, 0);
299 }
300
301 /*
@@ -303,15 +307,17 @@ struct progress *start_progress(const char *title, uint64_t total)
307 * When "sparse" is set, stop_progress() will automatically force the done
308 * message to show 100%.
309 */
306 -struct progress *start_sparse_progress(const char *title, uint64_t total)
310 +struct progress *start_sparse_progress(struct repository *r,
311 + const char *title, uint64_t total)
312 {
308 - return start_progress_delay(title, total, 0, 1);
313 + return start_progress_delay(r, title, total, 0, 1);
314 }
315
311 -struct progress *start_delayed_sparse_progress(const char *title,
316 +struct progress *start_delayed_sparse_progress(struct repository *r,
317 + const char *title,
318 uint64_t total)
319 {
314 - return start_progress_delay(title, total, get_default_delay(), 1);
320 + return start_progress_delay(r, title, total, get_default_delay(), 1);
321 }
322
323 static void finish_if_sparse(struct progress *progress)
@@ -341,14 +347,14 @@ static void force_last_update(struct progress *progress, const char *msg)
347
348 static void log_trace2(struct progress *progress)
349 {
344 - trace2_data_intmax("progress", the_repository, "total_objects",
350 + trace2_data_intmax("progress", progress->repo, "total_objects",
351 progress->total);
352
353 if (progress->throughput)
348 - trace2_data_intmax("progress", the_repository, "total_bytes",
354 + trace2_data_intmax("progress", progress->repo, "total_bytes",
355 progress->throughput->curr_total);
356
351 - trace2_region_leave("progress", progress->title, the_repository);
357 + trace2_region_leave("progress", progress->title, progress->repo);
358 }
359
360 void stop_progress_msg(struct progress **p_progress, const char *msg)
progress.h
+9 -4
@@ -3,6 +3,7 @@
3 #include "gettext.h"
4
5 struct progress;
6 +struct repository;
7
8 #ifdef GIT_TEST_PROGRESS_ONLY
9
@@ -14,10 +15,14 @@ void progress_test_force_update(void);
15
16 void display_throughput(struct progress *progress, uint64_t total);
17 void display_progress(struct progress *progress, uint64_t n);
17 -struct progress *start_progress(const char *title, uint64_t total);
18 -struct progress *start_sparse_progress(const char *title, uint64_t total);
19 -struct progress *start_delayed_progress(const char *title, uint64_t total);
20 -struct progress *start_delayed_sparse_progress(const char *title,
18 +struct progress *start_progress(struct repository *r,
19 + const char *title, uint64_t total);
20 +struct progress *start_sparse_progress(struct repository *r,
21 + const char *title, uint64_t total);
22 +struct progress *start_delayed_progress(struct repository *r,
23 + const char *title, uint64_t total);
24 +struct progress *start_delayed_sparse_progress(struct repository *r,
25 + const char *title,
26 uint64_t total);
27 void stop_progress_msg(struct progress **p_progress, const char *msg);
28 static inline void stop_progress(struct progress **p_progress)
prune-packed.c
+2 -1
@@ -37,7 +37,8 @@ static int prune_object(const struct object_id *oid, const char *path,
37 void prune_packed_objects(int opts)
38 {
39 if (opts & PRUNE_PACKED_VERBOSE)
40 - progress = start_delayed_progress(_("Removing duplicate objects"), 256);
40 + progress = start_delayed_progress(the_repository,
41 + _("Removing duplicate objects"), 256);
42
43 for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
44 prune_object, NULL, prune_subdir, &opts);
pseudo-merge.c
+2 -1
@@ -459,7 +459,8 @@ void select_pseudo_merges(struct bitmap_writer *writer)
459 return;
460
461 if (writer->show_progress)
462 - progress = start_progress("Selecting pseudo-merge commits",
462 + progress = start_progress(the_repository,
463 + "Selecting pseudo-merge commits",
464 writer->pseudo_merge_groups.nr);
465
466 refs_for_each_ref(get_main_ref_store(the_repository),
read-cache.c
+2 -1
@@ -1523,7 +1523,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
1523 int t2_sum_scan = 0;
1524
1525 if (flags & REFRESH_PROGRESS && isatty(2))
1526 - progress = start_delayed_progress(_("Refresh index"),
1526 + progress = start_delayed_progress(the_repository,
1527 + _("Refresh index"),
1528 istate->cache_nr);
1529
1530 trace_performance_enter();
t/helper/test-progress.c
+5 -1
@@ -17,10 +17,14 @@
17 *
18 * See 't0500-progress-display.sh' for examples.
19 */
20 +
21 +#define USE_THE_REPOSITORY_VARIABLE
22 #define GIT_TEST_PROGRESS_ONLY
23 +
24 #include "test-tool.h"
25 #include "parse-options.h"
26 #include "progress.h"
27 +#include "repository.h"
28 #include "strbuf.h"
29 #include "string-list.h"
30
@@ -64,7 +68,7 @@ int cmd__progress(int argc, const char **argv)
68 else
69 die("invalid input: '%s'", line.buf);
70
67 - progress = start_progress(title, total);
71 + progress = start_progress(the_repository, title, total);
72 } else if (skip_prefix(line.buf, "progress ", (const char **) &end)) {
73 uint64_t item_count = strtoull(end, &end, 10);
74 if (*end != '\0')
unpack-trees.c
+3 -1
@@ -372,7 +372,8 @@ static struct progress *get_progress(struct unpack_trees_options *o,
372 total++;
373 }
374
375 - return start_delayed_progress(_("Updating files"), total);
375 + return start_delayed_progress(the_repository,
376 + _("Updating files"), total);
377 }
378
379 static void setup_collided_checkout_detection(struct checkout *state,
@@ -1773,6 +1774,7 @@ static int clear_ce_flags(struct index_state *istate,
1774 strbuf_reset(&prefix);
1775 if (show_progress)
1776 istate->progress = start_delayed_progress(
1777 + the_repository,
1778 _("Updating index flags"),
1779 istate->cache_nr);
1780
walker.c
+2 -1
@@ -172,7 +172,8 @@ static int loop(struct walker *walker)
172 uint64_t nr = 0;
173
174 if (walker->get_progress)
175 - progress = start_delayed_progress(_("Fetching objects"), 0);
175 + progress = start_delayed_progress(the_repository,
176 + _("Fetching objects"), 0);
177
178 while (process_queue) {
179 struct object *obj = process_queue->item;