Skip to content

Commit 1f7e647

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 913a1e1 commit 1f7e647

27 files changed

+136
-59
lines changed

builtin/blame.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,9 @@ int cmd_blame(int argc,
11931193
sb.found_guilty_entry = &found_guilty_entry;
11941194
sb.found_guilty_entry_data = &pi;
11951195
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);
11971199

11981200
assign_blame(&sb, opt);
11991201

builtin/commit-graph.c

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
305305
oidset_init(&commits, 0);
306306
if (opts.progress)
307307
progress = start_delayed_progress(
308+
the_repository,
308309
_("Collecting commits from input"), 0);
309310

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

builtin/fsck.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ static int traverse_reachable(void)
197197
unsigned int nr = 0;
198198
int result = 0;
199199
if (show_progress)
200-
progress = start_delayed_progress(_("Checking connectivity"), 0);
200+
progress = start_delayed_progress(the_repository,
201+
_("Checking connectivity"), 0);
201202
while (pending.nr) {
202203
result |= traverse_one_object(object_array_pop(&pending));
203204
display_progress(progress, ++nr);
@@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)
703704
fprintf_ln(stderr, _("Checking object directory"));
704705

705706
if (show_progress)
706-
progress = start_progress(_("Checking object directories"), 256);
707+
progress = start_progress(the_repository,
708+
_("Checking object directories"), 256);
707709

708710
for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
709711
&cb_data);
@@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)
879881
if (show_progress) {
880882
for (struct packed_git *p = get_all_packs(r); p; p = p->next)
881883
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);
883886
pack_count = 0;
884887
}
885888

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

992-
progress = start_progress(_("Checking objects"), total);
995+
progress = start_progress(the_repository,
996+
_("Checking objects"), total);
993997
}
994998
for (p = get_all_packs(the_repository); p;
995999
p = p->next) {

builtin/index-pack.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ static unsigned check_objects(void)
282282
max = get_max_object_index();
283283

284284
if (verbose)
285-
progress = start_delayed_progress(_("Checking objects"), max);
285+
progress = start_delayed_progress(the_repository,
286+
_("Checking objects"), max);
286287

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

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

13311333
if (verbose || show_resolving_progress)
1332-
progress = start_progress(_("Resolving deltas"),
1334+
progress = start_progress(the_repository,
1335+
_("Resolving deltas"),
13331336
nr_ref_deltas + nr_ofs_deltas);
13341337

13351338
nr_dispatched = 0;

builtin/log.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,8 @@ int cmd_format_patch(int argc,
24952495
rev.add_signoff = cfg.do_signoff;
24962496

24972497
if (show_progress)
2498-
progress = start_delayed_progress(_("Generating patches"), total);
2498+
progress = start_delayed_progress(the_repository,
2499+
_("Generating patches"), total);
24992500
while (0 <= --nr) {
25002501
int shown;
25012502
display_progress(progress, total - nr);

builtin/pack-objects.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,8 @@ static void write_pack_file(void)
12641264
struct object_entry **write_order;
12651265

12661266
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);
12681269
ALLOC_ARRAY(written_list, to_pack.nr_objects);
12691270
write_order = compute_write_order();
12701271

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

24022403
if (progress)
2403-
progress_state = start_progress(_("Counting objects"),
2404+
progress_state = start_progress(the_repository,
2405+
_("Counting objects"),
24042406
to_pack.nr_objects);
24052407

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

32223224
if (progress)
3223-
progress_state = start_progress(_("Compressing objects"),
3225+
progress_state = start_progress(the_repository,
3226+
_("Compressing objects"),
32243227
nr_deltas);
32253228
QSORT(delta_list, n, type_size_sort);
32263229
ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
@@ -3648,7 +3651,8 @@ static void add_objects_in_unpacked_packs(void);
36483651
static void enumerate_cruft_objects(void)
36493652
{
36503653
if (progress)
3651-
progress_state = start_progress(_("Enumerating cruft objects"), 0);
3654+
progress_state = start_progress(the_repository,
3655+
_("Enumerating cruft objects"), 0);
36523656

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

36763680
if (progress)
3677-
progress_state = start_progress(_("Enumerating cruft objects"), 0);
3681+
progress_state = start_progress(the_repository,
3682+
_("Enumerating cruft objects"), 0);
36783683
ret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration,
36793684
set_cruft_mtime, 1);
36803685
stop_progress(&progress_state);
@@ -3693,7 +3698,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
36933698
if (prepare_revision_walk(&revs))
36943699
die(_("revision walk setup failed"));
36953700
if (progress)
3696-
progress_state = start_progress(_("Traversing cruft objects"), 0);
3701+
progress_state = start_progress(the_repository,
3702+
_("Traversing cruft objects"), 0);
36973703
nr_seen = 0;
36983704
traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);
36993705

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

46274633
if (progress && !cruft)
4628-
progress_state = start_progress(_("Enumerating objects"), 0);
4634+
progress_state = start_progress(the_repository,
4635+
_("Enumerating objects"), 0);
46294636
if (stdin_packs) {
46304637
/* avoids adding objects in excluded packs */
46314638
ignore_packed_keep_in_core = 1;

builtin/prune.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)
6464
return;
6565

6666
if (show_progress)
67-
progress = start_delayed_progress(_("Checking connectivity"), 0);
67+
progress = start_delayed_progress(the_repository,
68+
_("Checking connectivity"), 0);
6869
mark_reachable_objects(revs, 1, expire, progress);
6970
stop_progress(&progress);
7071
initialized = 1;

builtin/remote.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ static int mv(int argc, const char **argv, const char *prefix,
820820
* Count symrefs twice, since "renaming" them is done by
821821
* deleting and recreating them in two separate passes.
822822
*/
823-
progress = start_progress(_("Renaming remote references"),
823+
progress = start_progress(the_repository,
824+
_("Renaming remote references"),
824825
rename.remote_branches->nr + rename.symrefs_nr);
825826
}
826827
for (i = 0; i < remote_branches.nr; i++) {

builtin/rev-list.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ int cmd_rev_list(int argc,
735735
revs.limited = 1;
736736

737737
if (show_progress)
738-
progress = start_delayed_progress(show_progress, 0);
738+
progress = start_delayed_progress(the_repository,
739+
show_progress, 0);
739740

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

builtin/unpack-objects.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ static void unpack_all(void)
590590
use(sizeof(struct pack_header));
591591

592592
if (!quiet)
593-
progress = start_progress(_("Unpacking objects"), nr_objects);
593+
progress = start_progress(the_repository,
594+
_("Unpacking objects"), nr_objects);
594595
CALLOC_ARRAY(obj_list, nr_objects);
595596
begin_odb_transaction();
596597
for (i = 0; i < nr_objects; i++) {

commit-graph.c

+17-3
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
15341534

15351535
if (ctx->report_progress)
15361536
ctx->progress = start_delayed_progress(
1537+
the_repository,
15371538
_("Loading known commits in commit graph"),
15381539
ctx->oids.nr);
15391540
for (i = 0; i < ctx->oids.nr; i++) {
@@ -1551,6 +1552,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
15511552
*/
15521553
if (ctx->report_progress)
15531554
ctx->progress = start_delayed_progress(
1555+
the_repository,
15541556
_("Expanding reachable commits in commit graph"),
15551557
0);
15561558
for (i = 0; i < ctx->oids.nr; i++) {
@@ -1571,6 +1573,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
15711573

15721574
if (ctx->report_progress)
15731575
ctx->progress = start_delayed_progress(
1576+
the_repository,
15741577
_("Clearing commit marks in commit graph"),
15751578
ctx->oids.nr);
15761579
for (i = 0; i < ctx->oids.nr; i++) {
@@ -1688,6 +1691,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)
16881691
if (ctx->report_progress)
16891692
info.progress = ctx->progress
16901693
= start_delayed_progress(
1694+
the_repository,
16911695
_("Computing commit graph topological levels"),
16921696
ctx->commits.nr);
16931697

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

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

17991804
if (ctx->report_progress)
18001805
progress = start_delayed_progress(
1806+
the_repository,
18011807
_("Computing commit changed paths Bloom filters"),
18021808
ctx->commits.nr);
18031809

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

18821889
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,
19081915
"Finding commits for commit graph in %"PRIuMAX" packs",
19091916
pack_indexes->nr),
19101917
(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);
19121920
ctx->progress_done = 0;
19131921
}
19141922
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)
19591967
{
19601968
if (ctx->report_progress)
19611969
ctx->progress = start_delayed_progress(
1970+
the_repository,
19621971
_("Finding commits for commit graph among packed objects"),
19631972
ctx->approx_nr_objects);
19641973
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)
19771986
ctx->num_extra_edges = 0;
19781987
if (ctx->report_progress)
19791988
ctx->progress = start_delayed_progress(
1989+
the_repository,
19801990
_("Finding extra edges in commit graph"),
19811991
ctx->oids.nr);
19821992
oid_array_sort(&ctx->oids);
@@ -2136,6 +2146,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
21362146
get_num_chunks(cf)),
21372147
get_num_chunks(cf));
21382148
ctx->progress = start_delayed_progress(
2149+
the_repository,
21392150
progress_title.buf,
21402151
st_mult(get_num_chunks(cf), ctx->commits.nr));
21412152
}
@@ -2348,6 +2359,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
23482359

23492360
if (ctx->report_progress)
23502361
ctx->progress = start_delayed_progress(
2362+
the_repository,
23512363
_("Scanning merged commits"),
23522364
ctx->commits.nr);
23532365

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

23942406
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);
23962409

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

2877-
progress = start_progress(_("Verifying commits in commit graph"),
2890+
progress = start_progress(the_repository,
2891+
_("Verifying commits in commit graph"),
28782892
total);
28792893
}
28802894

delta-islands.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,
267267
QSORT(todo, nr, tree_depth_compare);
268268

269269
if (progress)
270-
progress_state = start_progress(_("Propagating island marks"), nr);
270+
progress_state = start_progress(the_repository,
271+
_("Propagating island marks"), nr);
271272

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

diffcore-rename.c

+1
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
15671567
trace2_region_enter("diff", "inexact renames", options->repo);
15681568
if (options->show_rename_progress) {
15691569
progress = start_delayed_progress(
1570+
the_repository,
15701571
_("Performing inexact rename detection"),
15711572
(uint64_t)num_destinations * (uint64_t)num_sources);
15721573
}

entry.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
188188

189189
dco->state = CE_RETRY;
190190
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);
192194
while (dco->filters.nr > 0) {
193195
for_each_string_list_item(filter, &dco->filters) {
194196
struct string_list available_paths = STRING_LIST_INIT_DUP;

midx-write.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
11311131

11321132
ctx.pack_paths_checked = 0;
11331133
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);
11351136
else
11361137
ctx.progress = NULL;
11371138

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

15411542
if (flags & MIDX_PROGRESS)
1542-
progress = start_delayed_progress(_("Counting referenced objects"),
1543+
progress = start_delayed_progress(
1544+
r,
1545+
_("Counting referenced objects"),
15431546
m->num_objects);
15441547
for (i = 0; i < m->num_objects; i++) {
15451548
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
15491552
stop_progress(&progress);
15501553

15511554
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"),
15531558
m->num_packs);
15541559
for (i = 0; i < m->num_packs; i++) {
15551560
char *pack_name;

0 commit comments

Comments
 (0)