Skip to content

Commit 9281cd0

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: avoid duplicated progress output during verify
When `git commit-graph verify` was taught how to verify commit-graph chains in 3da4b60 (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 <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7248857 commit 9281cd0

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

commit-graph.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,8 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
25452545

25462546
static int verify_one_commit_graph(struct repository *r,
25472547
struct commit_graph *g,
2548-
struct progress *progress)
2548+
struct progress *progress,
2549+
uint64_t *seen)
25492550
{
25502551
uint32_t i, cur_fanout_pos = 0;
25512552
struct object_id prev_oid, cur_oid;
@@ -2606,7 +2607,7 @@ static int verify_one_commit_graph(struct repository *r,
26062607
timestamp_t max_generation = 0;
26072608
timestamp_t generation;
26082609

2609-
display_progress(progress, i + 1);
2610+
display_progress(progress, ++(*seen));
26102611
oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i);
26112612

26122613
graph_commit = lookup_commit(r, &cur_oid);
@@ -2695,26 +2696,32 @@ static int verify_one_commit_graph(struct repository *r,
26952696

26962697
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
26972698
{
2699+
struct progress *progress = NULL;
26982700
int local_error = 0;
2701+
uint64_t seen = 0;
26992702

27002703
if (!g) {
27012704
graph_report("no commit-graph file loaded");
27022705
return 1;
27032706
}
27042707

2705-
for (; g; g = g->base_graph) {
2706-
struct progress *progress = NULL;
2707-
if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
2708-
progress = start_progress(_("Verifying commits in commit graph"),
2709-
g->num_commits);
2708+
if (flags & COMMIT_GRAPH_WRITE_PROGRESS) {
2709+
uint64_t total = g->num_commits;
2710+
if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))
2711+
total += g->num_commits_in_base;
2712+
2713+
progress = start_progress(_("Verifying commits in commit graph"),
2714+
total);
2715+
}
27102716

2711-
local_error |= verify_one_commit_graph(r, g, progress);
2717+
for (; g; g = g->base_graph) {
2718+
local_error |= verify_one_commit_graph(r, g, progress, &seen);
27122719
if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
27132720
break;
2714-
2715-
stop_progress(&progress);
27162721
}
27172722

2723+
stop_progress(&progress);
2724+
27182725
return local_error;
27192726
}
27202727

t/t5324-split-commit-graph.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ test_expect_success 'add octopus merge' '
351351
git branch merge/octopus &&
352352
git commit-graph write --reachable --split &&
353353
git commit-graph verify --progress 2>err &&
354-
test_line_count = 3 err &&
354+
test_line_count = 1 err &&
355+
grep "Verifying commits in commit graph: 100% (18/18)" err &&
355356
test_i18ngrep ! warning err &&
356357
test_line_count = 3 $graphdir/commit-graph-chain
357358
'

0 commit comments

Comments
 (0)