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

[PATCH 3/3] commit-graph: don't consider "replace" objects with "verify"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 14, 2021, 23:37 UTC
Message-ID
<patch-3.3-56bb70518cb-20211014T233343Z-avarab@gmail.com>
In-Reply-To
<cover-0.3-00000000000-20211014T233343Z-avarab@gmail.com>

Extend the code added in d6538246d3d (commit-graph: not compatible with replace objects, 2018-08-20) which ignored replace objects in the "write" command to ignore it in the "verify" command too.

We can just move this assignment to the cmd_commit_graph(), it dispatches to "write" and "verify", and we're unlikely to ever get a sub-command that would like to consider replace refs.

This will make tests added in eddc1f556cd (mktag tests: test update-ref and reachable fsck, 2021-06-17) pass in combination with the "GIT_TEST_COMMIT_GRAPH" mode added in 859fdc0c3cf (commit-graph: define GIT_TEST_COMMIT_GRAPH, 2018-08-29), except that mode is currently broken (but is being fixed concurrently). See the discussion starting at [1].

1. https://lore.kernel.org/git/87wnmihswp.fsf@evledraar.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit-graph.c  | 2 +-
 t/t5318-commit-graph.sh | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 3c3de3a156f..fb8e166a26f 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -263,7 +263,6 @@ static int graph_write(int argc, const char **argv)
 	    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
 		flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
 
-	read_replace_refs = 0;
 	odb = find_odb(the_repository, opts.obj_dir);
 
 	if (opts.reachable) {
@@ -318,6 +317,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
 	if (!argc)
 		goto usage;
 
+	read_replace_refs = 0;
 	save_commit_buffer = 0;
 
 	if (!strcmp(argv[0], "verify"))
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 88fbe004a38..84d122a7ae7 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -385,6 +385,7 @@ test_expect_success 'replace-objects invalidates commit-graph' '
 		git commit-graph write --reachable &&
 		test_path_is_file .git/objects/info/commit-graph &&
 		git replace HEAD~1 HEAD~2 &&
+		graph_git_two_modes "commit-graph verify" &&
 		git -c core.commitGraph=false log >expect &&
 		git -c core.commitGraph=true log >actual &&
 		test_cmp expect actual &&
-- 
2.33.1.1338.g20da966911a
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “commit-graph: make "verify" work with replace refs”
  1. 0/3 commit-graph: make "verify" work with replace refsÆvar Arnfjörð Bjarmason, Oct 14, 2021
  2. 1/3 commit-graph tests: fix error-hiding graph_git_two_modes() helperÆvar Arnfjörð Bjarmason, Oct 14, 2021
  3. Junio C HamanoOct 15, 2021
  4. 2/3 commit-graph tests: fix another graph_git_two_modes() helperÆvar Arnfjörð Bjarmason, Oct 14, 2021
  5. Junio C HamanoOct 15, 2021
  6. 3/3 commit-graph: don't consider "replace" objects with "verify"Ævar Arnfjörð Bjarmason, Oct 14, 2021
  7. Junio C HamanoOct 15, 2021

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.