Skip to content

Commit 6016ee0

Browse files
committed
Merge branch 'tb/fsck-no-progress'
"git fsck --no-progress" still spewed noise from the commit-graph subsystem, which has been corrected. * tb/fsck-no-progress: commit-graph.c: avoid duplicated progress output during `verify` commit-graph.c: pass progress to `verify_one_commit_graph()` commit-graph.c: iteratively verify commit-graph chains commit-graph.c: extract `verify_one_commit_graph()` fsck: suppress MIDX output with `--no-progress` fsck: suppress commit-graph output with `--no-progress`
2 parents d6e6722 + 9281cd0 commit 6016ee0

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed

builtin/fsck.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,10 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
10741074
commit_graph_verify.git_cmd = 1;
10751075
strvec_pushl(&commit_graph_verify.args, "commit-graph",
10761076
"verify", "--object-dir", odb->path, NULL);
1077+
if (show_progress)
1078+
strvec_push(&commit_graph_verify.args, "--progress");
1079+
else
1080+
strvec_push(&commit_graph_verify.args, "--no-progress");
10771081
if (run_command(&commit_graph_verify))
10781082
errors_found |= ERROR_COMMIT_GRAPH;
10791083
}
@@ -1088,6 +1092,10 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
10881092
midx_verify.git_cmd = 1;
10891093
strvec_pushl(&midx_verify.args, "multi-pack-index",
10901094
"verify", "--object-dir", odb->path, NULL);
1095+
if (show_progress)
1096+
strvec_push(&midx_verify.args, "--progress");
1097+
else
1098+
strvec_push(&midx_verify.args, "--no-progress");
10911099
if (run_command(&midx_verify))
10921100
errors_found |= ERROR_MULTI_PACK_INDEX;
10931101
}

commit-graph.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,18 +2541,14 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
25412541
return hashfile_checksum_valid(g->data, g->data_len);
25422542
}
25432543

2544-
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2544+
static int verify_one_commit_graph(struct repository *r,
2545+
struct commit_graph *g,
2546+
struct progress *progress,
2547+
uint64_t *seen)
25452548
{
25462549
uint32_t i, cur_fanout_pos = 0;
25472550
struct object_id prev_oid, cur_oid;
25482551
int generation_zero = 0;
2549-
struct progress *progress = NULL;
2550-
int local_error = 0;
2551-
2552-
if (!g) {
2553-
graph_report("no commit-graph file loaded");
2554-
return 1;
2555-
}
25562552

25572553
verify_commit_graph_error = verify_commit_graph_lite(g);
25582554
if (verify_commit_graph_error)
@@ -2603,17 +2599,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
26032599
if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
26042600
return verify_commit_graph_error;
26052601

2606-
if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
2607-
progress = start_progress(_("Verifying commits in commit graph"),
2608-
g->num_commits);
2609-
26102602
for (i = 0; i < g->num_commits; i++) {
26112603
struct commit *graph_commit, *odb_commit;
26122604
struct commit_list *graph_parents, *odb_parents;
26132605
timestamp_t max_generation = 0;
26142606
timestamp_t generation;
26152607

2616-
display_progress(progress, i + 1);
2608+
display_progress(progress, ++(*seen));
26172609
oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i);
26182610

26192611
graph_commit = lookup_commit(r, &cur_oid);
@@ -2696,12 +2688,37 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
26962688
graph_commit->date,
26972689
odb_commit->date);
26982690
}
2699-
stop_progress(&progress);
27002691

2701-
local_error = verify_commit_graph_error;
2692+
return verify_commit_graph_error;
2693+
}
2694+
2695+
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2696+
{
2697+
struct progress *progress = NULL;
2698+
int local_error = 0;
2699+
uint64_t seen = 0;
2700+
2701+
if (!g) {
2702+
graph_report("no commit-graph file loaded");
2703+
return 1;
2704+
}
2705+
2706+
if (flags & COMMIT_GRAPH_WRITE_PROGRESS) {
2707+
uint64_t total = g->num_commits;
2708+
if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))
2709+
total += g->num_commits_in_base;
2710+
2711+
progress = start_progress(_("Verifying commits in commit graph"),
2712+
total);
2713+
}
2714+
2715+
for (; g; g = g->base_graph) {
2716+
local_error |= verify_one_commit_graph(r, g, progress, &seen);
2717+
if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
2718+
break;
2719+
}
27022720

2703-
if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW) && g->base_graph)
2704-
local_error |= verify_commit_graph(r, g->base_graph, flags);
2721+
stop_progress(&progress);
27052722

27062723
return local_error;
27072724
}

t/t5318-commit-graph.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,16 @@ test_expect_success 'git fsck (checks commit-graph when config unset)' '
684684
test_must_fail git fsck
685685
'
686686

687+
test_expect_success 'git fsck shows commit-graph output with --progress' '
688+
git -C "$TRASH_DIRECTORY/full" fsck --progress 2>err &&
689+
grep "Verifying commits in commit graph" err
690+
'
691+
692+
test_expect_success 'git fsck suppresses commit-graph output with --no-progress' '
693+
git -C "$TRASH_DIRECTORY/full" fsck --no-progress 2>err &&
694+
! grep "Verifying commits in commit graph" err
695+
'
696+
687697
test_expect_success 'setup non-the_repository tests' '
688698
rm -rf repo &&
689699
git init repo &&

t/t5319-multi-pack-index.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,18 @@ test_expect_success 'git-fsck incorrect offset' '
485485
git -c core.multiPackIndex=false fsck
486486
'
487487

488+
test_expect_success 'git fsck shows MIDX output with --progress' '
489+
git fsck --progress 2>err &&
490+
grep "Verifying OID order in multi-pack-index" err &&
491+
grep "Verifying object offsets" err
492+
'
493+
494+
test_expect_success 'git fsck suppresses MIDX output with --no-progress' '
495+
git fsck --no-progress 2>err &&
496+
! grep "Verifying OID order in multi-pack-index" err &&
497+
! grep "Verifying object offsets" err
498+
'
499+
488500
test_expect_success 'corrupt MIDX is not reused' '
489501
corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \
490502
"incorrect object offset" &&

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)