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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 14 additions & 7 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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++) {

0 commit comments

Comments
 (0)