mirror of
https://github.com/git/git.git
synced 2025-02-06 09:44:30 +00:00
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>
This commit is contained in:
parent
913a1e157c
commit
1f7e6478dc
@ -1193,7 +1193,9 @@ parse_done:
|
||||
sb.found_guilty_entry = &found_guilty_entry;
|
||||
sb.found_guilty_entry_data = π
|
||||
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);
|
||||
|
||||
|
@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
|
||||
oidset_init(&commits, 0);
|
||||
if (opts.progress)
|
||||
progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Collecting commits from input"), 0);
|
||||
|
||||
while (strbuf_getline(&buf, stdin) != EOF) {
|
||||
|
@ -197,7 +197,8 @@ static int traverse_reachable(void)
|
||||
unsigned int nr = 0;
|
||||
int result = 0;
|
||||
if (show_progress)
|
||||
progress = start_delayed_progress(_("Checking connectivity"), 0);
|
||||
progress = start_delayed_progress(the_repository,
|
||||
_("Checking connectivity"), 0);
|
||||
while (pending.nr) {
|
||||
result |= traverse_one_object(object_array_pop(&pending));
|
||||
display_progress(progress, ++nr);
|
||||
@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)
|
||||
fprintf_ln(stderr, _("Checking object directory"));
|
||||
|
||||
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,
|
||||
&cb_data);
|
||||
@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)
|
||||
if (show_progress) {
|
||||
for (struct packed_git *p = get_all_packs(r); p; p = p->next)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -989,7 +992,8 @@ int cmd_fsck(int argc,
|
||||
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;
|
||||
p = p->next) {
|
||||
|
@ -282,7 +282,8 @@ static unsigned check_objects(void)
|
||||
max = get_max_object_index();
|
||||
|
||||
if (verbose)
|
||||
progress = start_delayed_progress(_("Checking objects"), max);
|
||||
progress = start_delayed_progress(the_repository,
|
||||
_("Checking objects"), max);
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
foreign_nr += check_object(get_indexed_object(i));
|
||||
@ -1249,6 +1250,7 @@ static void parse_pack_objects(unsigned char *hash)
|
||||
|
||||
if (verbose)
|
||||
progress = start_progress(
|
||||
the_repository,
|
||||
progress_title ? progress_title :
|
||||
from_stdin ? _("Receiving objects") : _("Indexing 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);
|
||||
|
||||
if (verbose || show_resolving_progress)
|
||||
progress = start_progress(_("Resolving deltas"),
|
||||
progress = start_progress(the_repository,
|
||||
_("Resolving deltas"),
|
||||
nr_ref_deltas + nr_ofs_deltas);
|
||||
|
||||
nr_dispatched = 0;
|
||||
|
@ -2495,7 +2495,8 @@ int cmd_format_patch(int argc,
|
||||
rev.add_signoff = cfg.do_signoff;
|
||||
|
||||
if (show_progress)
|
||||
progress = start_delayed_progress(_("Generating patches"), total);
|
||||
progress = start_delayed_progress(the_repository,
|
||||
_("Generating patches"), total);
|
||||
while (0 <= --nr) {
|
||||
int shown;
|
||||
display_progress(progress, total - nr);
|
||||
|
@ -1264,7 +1264,8 @@ static void write_pack_file(void)
|
||||
struct object_entry **write_order;
|
||||
|
||||
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);
|
||||
write_order = compute_write_order();
|
||||
|
||||
@ -2400,7 +2401,8 @@ static void get_object_details(void)
|
||||
struct object_entry **sorted_by_offset;
|
||||
|
||||
if (progress)
|
||||
progress_state = start_progress(_("Counting objects"),
|
||||
progress_state = start_progress(the_repository,
|
||||
_("Counting objects"),
|
||||
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;
|
||||
|
||||
if (progress)
|
||||
progress_state = start_progress(_("Compressing objects"),
|
||||
progress_state = start_progress(the_repository,
|
||||
_("Compressing objects"),
|
||||
nr_deltas);
|
||||
QSORT(delta_list, n, type_size_sort);
|
||||
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)
|
||||
{
|
||||
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_unreachable_loose_objects();
|
||||
@ -3674,7 +3678,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
|
||||
revs.ignore_missing_links = 1;
|
||||
|
||||
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,
|
||||
set_cruft_mtime, 1);
|
||||
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))
|
||||
die(_("revision walk setup failed"));
|
||||
if (progress)
|
||||
progress_state = start_progress(_("Traversing cruft objects"), 0);
|
||||
progress_state = start_progress(the_repository,
|
||||
_("Traversing cruft objects"), 0);
|
||||
nr_seen = 0;
|
||||
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);
|
||||
|
||||
if (progress && !cruft)
|
||||
progress_state = start_progress(_("Enumerating objects"), 0);
|
||||
progress_state = start_progress(the_repository,
|
||||
_("Enumerating objects"), 0);
|
||||
if (stdin_packs) {
|
||||
/* avoids adding objects in excluded packs */
|
||||
ignore_packed_keep_in_core = 1;
|
||||
|
@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)
|
||||
return;
|
||||
|
||||
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);
|
||||
stop_progress(&progress);
|
||||
initialized = 1;
|
||||
|
@ -820,7 +820,8 @@ static int mv(int argc, const char **argv, const char *prefix,
|
||||
* Count symrefs twice, since "renaming" them is done by
|
||||
* 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);
|
||||
}
|
||||
for (i = 0; i < remote_branches.nr; i++) {
|
||||
|
@ -735,7 +735,8 @@ int cmd_rev_list(int argc,
|
||||
revs.limited = 1;
|
||||
|
||||
if (show_progress)
|
||||
progress = start_delayed_progress(show_progress, 0);
|
||||
progress = start_delayed_progress(the_repository,
|
||||
show_progress, 0);
|
||||
|
||||
if (use_bitmap_index) {
|
||||
if (!try_bitmap_count(&revs, filter_provided_objects))
|
||||
|
@ -590,7 +590,8 @@ static void unpack_all(void)
|
||||
use(sizeof(struct pack_header));
|
||||
|
||||
if (!quiet)
|
||||
progress = start_progress(_("Unpacking objects"), nr_objects);
|
||||
progress = start_progress(the_repository,
|
||||
_("Unpacking objects"), nr_objects);
|
||||
CALLOC_ARRAY(obj_list, nr_objects);
|
||||
begin_odb_transaction();
|
||||
for (i = 0; i < nr_objects; i++) {
|
||||
|
@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
|
||||
|
||||
if (ctx->report_progress)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Loading known commits in commit graph"),
|
||||
ctx->oids.nr);
|
||||
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)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Expanding reachable commits in commit graph"),
|
||||
0);
|
||||
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)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Clearing commit marks in commit graph"),
|
||||
ctx->oids.nr);
|
||||
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)
|
||||
info.progress = ctx->progress
|
||||
= start_delayed_progress(
|
||||
the_repository,
|
||||
_("Computing commit graph topological levels"),
|
||||
ctx->commits.nr);
|
||||
|
||||
@ -1722,6 +1726,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
|
||||
if (ctx->report_progress)
|
||||
info.progress = ctx->progress
|
||||
= start_delayed_progress(
|
||||
the_repository,
|
||||
_("Computing commit graph generation numbers"),
|
||||
ctx->commits.nr);
|
||||
|
||||
@ -1798,6 +1803,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
|
||||
|
||||
if (ctx->report_progress)
|
||||
progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Computing commit changed paths Bloom filters"),
|
||||
ctx->commits.nr);
|
||||
|
||||
@ -1877,6 +1883,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
|
||||
data.commits = &commits;
|
||||
if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
|
||||
data.progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Collecting referenced commits"), 0);
|
||||
|
||||
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",
|
||||
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;
|
||||
}
|
||||
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)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Finding commits for commit graph among packed objects"),
|
||||
ctx->approx_nr_objects);
|
||||
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;
|
||||
if (ctx->report_progress)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Finding extra edges in commit graph"),
|
||||
ctx->oids.nr);
|
||||
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));
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
progress_title.buf,
|
||||
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)
|
||||
ctx->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Scanning merged commits"),
|
||||
ctx->commits.nr);
|
||||
|
||||
@ -2392,7 +2404,8 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx)
|
||||
current_graph_number--;
|
||||
|
||||
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);
|
||||
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))
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,
|
||||
QSORT(todo, nr, tree_depth_compare);
|
||||
|
||||
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++) {
|
||||
struct object_entry *ent = todo[i].entry;
|
||||
|
@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
|
||||
trace2_region_enter("diff", "inexact renames", options->repo);
|
||||
if (options->show_rename_progress) {
|
||||
progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Performing inexact rename detection"),
|
||||
(uint64_t)num_destinations * (uint64_t)num_sources);
|
||||
}
|
||||
|
4
entry.c
4
entry.c
@ -188,7 +188,9 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
|
||||
|
||||
dco->state = CE_RETRY;
|
||||
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) {
|
||||
for_each_string_list_item(filter, &dco->filters) {
|
||||
struct string_list available_paths = STRING_LIST_INIT_DUP;
|
||||
|
11
midx-write.c
11
midx-write.c
@ -1131,7 +1131,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
|
||||
|
||||
ctx.pack_paths_checked = 0;
|
||||
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
|
||||
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);
|
||||
|
||||
if (flags & MIDX_PROGRESS)
|
||||
progress = start_delayed_progress(_("Counting referenced objects"),
|
||||
progress = start_delayed_progress(
|
||||
r,
|
||||
_("Counting referenced objects"),
|
||||
m->num_objects);
|
||||
for (i = 0; i < m->num_objects; 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);
|
||||
|
||||
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);
|
||||
for (i = 0; i < m->num_packs; i++) {
|
||||
char *pack_name;
|
||||
|
13
midx.c
13
midx.c
@ -907,7 +907,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
|
||||
midx_report(_("incorrect checksum"));
|
||||
|
||||
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);
|
||||
for (i = 0; i < m->num_packs + m->num_packs_in_base; 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)
|
||||
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);
|
||||
|
||||
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)
|
||||
progress = start_sparse_progress(_("Sorting objects by packfile"),
|
||||
progress = start_sparse_progress(r,
|
||||
_("Sorting objects by packfile"),
|
||||
m->num_objects);
|
||||
display_progress(progress, 0); /* TODO: Measure QSORT() progress */
|
||||
QSORT(pairs, m->num_objects, compare_pair_pos_vs_id);
|
||||
stop_progress(&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++) {
|
||||
struct object_id oid;
|
||||
struct pack_entry e;
|
||||
|
@ -590,7 +590,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)
|
||||
int closed = 1; /* until proven otherwise */
|
||||
|
||||
if (writer->show_progress)
|
||||
writer->progress = start_progress("Building bitmaps",
|
||||
writer->progress = start_progress(the_repository,
|
||||
"Building bitmaps",
|
||||
writer->selected_nr);
|
||||
trace2_region_enter("pack-bitmap-write", "building_bitmaps_total",
|
||||
the_repository);
|
||||
@ -710,7 +711,8 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,
|
||||
}
|
||||
|
||||
if (writer->show_progress)
|
||||
writer->progress = start_progress("Selecting bitmap commits", 0);
|
||||
writer->progress = start_progress(the_repository,
|
||||
"Selecting bitmap commits", 0);
|
||||
|
||||
for (;;) {
|
||||
struct commit *chosen = NULL;
|
||||
|
@ -2578,7 +2578,9 @@ void test_bitmap_walk(struct rev_info *revs)
|
||||
tdata.trees = ewah_to_bitmap(bitmap_git->trees);
|
||||
tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);
|
||||
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;
|
||||
|
||||
traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);
|
||||
|
@ -132,7 +132,9 @@ void preload_index(struct index_state *index,
|
||||
|
||||
memset(&pd, 0, sizeof(pd));
|
||||
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);
|
||||
}
|
||||
|
||||
|
34
progress.c
34
progress.c
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#define GIT_TEST_PROGRESS_ONLY
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||
|
||||
#include "git-compat-util.h"
|
||||
@ -37,6 +36,7 @@ struct throughput {
|
||||
};
|
||||
|
||||
struct progress {
|
||||
struct repository *repo;
|
||||
const char *title;
|
||||
uint64_t last_value;
|
||||
uint64_t total;
|
||||
@ -254,10 +254,12 @@ void display_progress(struct progress *progress, uint64_t n)
|
||||
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)
|
||||
{
|
||||
struct progress *progress = xmalloc(sizeof(*progress));
|
||||
progress->repo = r;
|
||||
progress->title = title;
|
||||
progress->total = total;
|
||||
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->split = 0;
|
||||
set_progress_signal();
|
||||
trace2_region_enter("progress", title, the_repository);
|
||||
trace2_region_enter("progress", title, r);
|
||||
return progress;
|
||||
}
|
||||
|
||||
@ -284,14 +286,16 @@ static int get_default_delay(void)
|
||||
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
|
||||
* 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)
|
||||
{
|
||||
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)
|
||||
@ -341,14 +347,14 @@ static void force_last_update(struct progress *progress, const char *msg)
|
||||
|
||||
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);
|
||||
|
||||
if (progress->throughput)
|
||||
trace2_data_intmax("progress", the_repository, "total_bytes",
|
||||
trace2_data_intmax("progress", progress->repo, "total_bytes",
|
||||
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)
|
||||
|
13
progress.h
13
progress.h
@ -3,6 +3,7 @@
|
||||
#include "gettext.h"
|
||||
|
||||
struct progress;
|
||||
struct repository;
|
||||
|
||||
#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_progress(struct progress *progress, uint64_t n);
|
||||
struct progress *start_progress(const char *title, uint64_t total);
|
||||
struct progress *start_sparse_progress(const char *title, uint64_t total);
|
||||
struct progress *start_delayed_progress(const char *title, uint64_t total);
|
||||
struct progress *start_delayed_sparse_progress(const char *title,
|
||||
struct progress *start_progress(struct repository *r,
|
||||
const char *title, uint64_t total);
|
||||
struct progress *start_sparse_progress(struct repository *r,
|
||||
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);
|
||||
void stop_progress_msg(struct progress **p_progress, const char *msg);
|
||||
static inline void stop_progress(struct progress **p_progress)
|
||||
|
@ -37,7 +37,8 @@ static int prune_object(const struct object_id *oid, const char *path,
|
||||
void prune_packed_objects(int opts)
|
||||
{
|
||||
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),
|
||||
prune_object, NULL, prune_subdir, &opts);
|
||||
|
@ -459,7 +459,8 @@ void select_pseudo_merges(struct bitmap_writer *writer)
|
||||
return;
|
||||
|
||||
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);
|
||||
|
||||
refs_for_each_ref(get_main_ref_store(the_repository),
|
||||
|
@ -1523,7 +1523,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
|
||||
int t2_sum_scan = 0;
|
||||
|
||||
if (flags & REFRESH_PROGRESS && isatty(2))
|
||||
progress = start_delayed_progress(_("Refresh index"),
|
||||
progress = start_delayed_progress(the_repository,
|
||||
_("Refresh index"),
|
||||
istate->cache_nr);
|
||||
|
||||
trace_performance_enter();
|
||||
|
@ -17,10 +17,14 @@
|
||||
*
|
||||
* See 't0500-progress-display.sh' for examples.
|
||||
*/
|
||||
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define GIT_TEST_PROGRESS_ONLY
|
||||
|
||||
#include "test-tool.h"
|
||||
#include "parse-options.h"
|
||||
#include "progress.h"
|
||||
#include "repository.h"
|
||||
#include "strbuf.h"
|
||||
#include "string-list.h"
|
||||
|
||||
@ -64,7 +68,7 @@ int cmd__progress(int argc, const char **argv)
|
||||
else
|
||||
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)) {
|
||||
uint64_t item_count = strtoull(end, &end, 10);
|
||||
if (*end != '\0')
|
||||
|
@ -372,7 +372,8 @@ static struct progress *get_progress(struct unpack_trees_options *o,
|
||||
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,
|
||||
@ -1773,6 +1774,7 @@ static int clear_ce_flags(struct index_state *istate,
|
||||
strbuf_reset(&prefix);
|
||||
if (show_progress)
|
||||
istate->progress = start_delayed_progress(
|
||||
the_repository,
|
||||
_("Updating index flags"),
|
||||
istate->cache_nr);
|
||||
|
||||
|
3
walker.c
3
walker.c
@ -172,7 +172,8 @@ static int loop(struct walker *walker)
|
||||
uint64_t nr = 0;
|
||||
|
||||
if (walker->get_progress)
|
||||
progress = start_delayed_progress(_("Fetching objects"), 0);
|
||||
progress = start_delayed_progress(the_repository,
|
||||
_("Fetching objects"), 0);
|
||||
|
||||
while (process_queue) {
|
||||
struct object *obj = process_queue->item;
|
||||
|
Loading…
x
Reference in New Issue
Block a user