Skip to content

Commit 4011224

Browse files
szedergitster
authored andcommitted
commit-graph: fix bogus counter in "Scanning merged commits" progress line
The final value of the counter of the "Scanning merged commits" progress line is always one less than its expected total, e.g.: Scanning merged commits: 83% (5/6), done. This happens because while iterating over an array the loop variable is passed to display_progress() as-is, but while C arrays (and thus the loop variable) start at 0 and end at N-1, the progress counter must end at N. Fix this by passing 'i + 1' to display_progress(), like most other callsites do. There's an RFC series to add a GIT_TEST_CHECK_PROGRESS=1 mode[1] which catches this issue in the 'fetch.writeCommitGraph' and 'fetch.writeCommitGraph with submodules' tests in 't5510-fetch.sh'. The GIT_TEST_CHECK_PROGRESS=1 mode is not part of this series, but future changes to progress.c may add it or similar assertions to catch this and similar bugs elsewhere. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a132c6 commit 4011224

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
20962096

20972097
ctx->num_extra_edges = 0;
20982098
for (i = 0; i < ctx->commits.nr; i++) {
2099-
display_progress(ctx->progress, i);
2099+
display_progress(ctx->progress, i + 1);
21002100

21012101
if (i && oideq(&ctx->commits.list[i - 1]->object.oid,
21022102
&ctx->commits.list[i]->object.oid)) {

0 commit comments

Comments
 (0)