git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/6] commit-graph.c: pass progress to `verify_one_commit_graph()`

From
Taylor Blau <me@ttaylorr.com>
Date
Jul 8, 2023, 00:31 UTC
Message-ID
<60fc2899d867c9532b5e5f79c3fcd4614726b393.1688776280.git.me@ttaylorr.com>
In-Reply-To
<cover.1688776280.git.me@ttaylorr.com>

This is the final step to prepare for consolidating the output of `git commit-graph verify`. Instead of having each call to `verify_one_commit_graph()` initialize its own progress struct, have the caller pass one in instead.

This patch does not alter the output of `git commit-graph verify`, but the next commit will consolidate the output.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 commit-graph.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c
index 3c29ea7c706..65dd4edf0e1 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2544,12 +2544,11 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
 
 static int verify_one_commit_graph(struct repository *r,
 				   struct commit_graph *g,
-				   int flags)
+				   struct progress *progress)
 {
 	uint32_t i, cur_fanout_pos = 0;
 	struct object_id prev_oid, cur_oid;
 	int generation_zero = 0;
-	struct progress *progress = NULL;
 
 	verify_commit_graph_error = verify_commit_graph_lite(g);
 	if (verify_commit_graph_error)
@@ -2600,10 +2599,6 @@ static int verify_one_commit_graph(struct repository *r,
 	if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
 		return verify_commit_graph_error;
 
-	if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
-		progress = start_progress(_("Verifying commits in commit graph"),
-					g->num_commits);
-
 	for (i = 0; i < g->num_commits; i++) {
 		struct commit *graph_commit, *odb_commit;
 		struct commit_list *graph_parents, *odb_parents;
@@ -2693,7 +2688,6 @@ static int verify_one_commit_graph(struct repository *r,
 				     graph_commit->date,
 				     odb_commit->date);
 	}
-	stop_progress(&progress);
 
 	return verify_commit_graph_error;
 }
@@ -2708,9 +2702,16 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 	}
 
 	for (; g; g = g->base_graph) {
-		local_error |= verify_one_commit_graph(r, g, flags);
+		struct progress *progress = NULL;
+		if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
+			progress = start_progress(_("Verifying commits in commit graph"),
+						g->num_commits);
+
+		local_error |= verify_one_commit_graph(r, g, progress);
 		if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
 			break;
+
+		stop_progress(&progress);
 	}
 
 	return local_error;
-- 
2.41.0.242.g6eec849fa5a
Previous: Taylor BlauNext: Taylor Blau
Message 6 of 8 in “fsck: squelch progress output with `--no-progress`”
  1. 0/6 fsck: squelch progress output with `--no-progress`Taylor Blau, Jul 8, 2023
  2. 1/6 fsck: suppress commit-graph output with `--no-progress`Taylor Blau, Jul 8, 2023
  3. 2/6 fsck: suppress MIDX output with `--no-progress`Taylor Blau, Jul 8, 2023
  4. 3/6 commit-graph.c: extract `verify_one_commit_graph()`Taylor Blau, Jul 8, 2023
  5. 4/6 commit-graph.c: iteratively verify commit-graph chainsTaylor Blau, Jul 8, 2023
  6. 5/6 commit-graph.c: pass progress to `verify_one_commit_graph()`Taylor Blau, Jul 8, 2023
  7. 6/6 commit-graph.c: avoid duplicated progress output during `verify`Taylor Blau, Jul 8, 2023
  8. Derrick StoleeJul 10, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.