Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-07-08 03:31:45 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-10 20:02:45 +0300
commit9281cd07f014263b5385f13b47ff8399282c7cdc (patch)
tree5cd1997c9c680ef91532a4828bd1dae8bd4a97b4 /commit-graph.c
parent7248857b6e74bb989dd067d2ac53605e77764700 (diff)
commit-graph.c: avoid duplicated progress output during `verify`
When `git commit-graph verify` was taught how to verify commit-graph chains in 3da4b609bb1 (commit-graph: verify chains with --shallow mode, 2019-06-18), it produced one line of progress per layer of the commit-graph chain. $ git.compile commit-graph verify Verifying commits in commit graph: 100% (4356/4356), done. Verifying commits in commit graph: 100% (131912/131912), done. This could be somewhat confusing to users, who may wonder why there are multiple occurrences of "Verifying commits in commit graph". There are likely good arguments on whether or not there should be one line of progress output per commit-graph layer. On the one hand, the existing output shows us verifying each individual layer of the chain. But on the other hand, the fact that a commit-graph may be stored among multiple layers is an implementation detail that the caller need not be aware of. Clarify this by showing a single progress meter regardless of the number of layers in the commit-graph chain. After this patch, the output reflects the logical contents of a commit-graph chain, instead of showing one line of output per commit-graph layer: $ git.compile commit-graph verify Verifying commits in commit graph: 100% (136268/136268), done. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 9e89952831..fda4b6e14d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2545,7 +2545,8 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
static int verify_one_commit_graph(struct repository *r,
struct commit_graph *g,
- struct progress *progress)
+ struct progress *progress,
+ uint64_t *seen)
{
uint32_t i, cur_fanout_pos = 0;
struct object_id prev_oid, cur_oid;
@@ -2606,7 +2607,7 @@ static int verify_one_commit_graph(struct repository *r,
timestamp_t max_generation = 0;
timestamp_t generation;
- display_progress(progress, i + 1);
+ display_progress(progress, ++(*seen));
oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i);
graph_commit = lookup_commit(r, &cur_oid);
@@ -2695,26 +2696,32 @@ static int verify_one_commit_graph(struct repository *r,
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
{
+ struct progress *progress = NULL;
int local_error = 0;
+ uint64_t seen = 0;
if (!g) {
graph_report("no commit-graph file loaded");
return 1;
}
- for (; g; g = g->base_graph) {
- struct progress *progress = NULL;
- if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
- progress = start_progress(_("Verifying commits in commit graph"),
- g->num_commits);
+ if (flags & COMMIT_GRAPH_WRITE_PROGRESS) {
+ uint64_t total = g->num_commits;
+ if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))
+ total += g->num_commits_in_base;
+
+ progress = start_progress(_("Verifying commits in commit graph"),
+ total);
+ }
- local_error |= verify_one_commit_graph(r, g, progress);
+ for (; g; g = g->base_graph) {
+ local_error |= verify_one_commit_graph(r, g, progress, &seen);
if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
break;
-
- stop_progress(&progress);
}
+ stop_progress(&progress);
+
return local_error;
}