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

[PATCH v4 1/2] t5510-fetch.sh: demonstrate fetch.writeCommitGraph bug

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 24, 2019, 13:40 UTC
Message-ID
<81501084713c129327d150c66779505ca4f1b271.1571924442.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.415.v4.git.1571924442.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

While dogfooding, Johannes found a bug in the fetch.writeCommitGraph config behavior. His example initially happened during a clone with --recurse-submodules, we found that this happens with the first fetch after cloning a repository that contains a submodule:

	$ git clone <url> test
	$ cd test
	$ git -c fetch.writeCommitGraph=true fetch origin
	Computing commit graph generation numbers: 100% (12/12), done.
	BUG: commit-graph.c:886: missing parent <hash1> for commit <hash2>
	Aborted (core dumped)

In the repo I had cloned, there were really 60 commits to scan, but only 12 were in the list to write when calling compute_generation_numbers(). A commit in the list expects to see a parent, but that parent is not in the list.

A follow-up will fix the bug, but first we create a test that demonstrates the problem. This test must be careful about an existing commit-graph file, since GIT_TEST_COMMIT_GRAPH=1 will cause the repo we are cloning to already have one. This then prevents the incremtnal commit-graph write during the first 'git fetch'.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Szeder Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 t/t5510-fetch.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ecabbe1616..195781ce8d 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -583,6 +583,22 @@ test_expect_success 'fetch.writeCommitGraph' '
 	)
 '
 
+test_expect_failure 'fetch.writeCommitGraph with submodules' '
+	git clone dups super &&
+	(
+		cd super &&
+		git submodule add "file://$TRASH_DIRECTORY/three" &&
+		git commit -m "add submodule"
+	) &&
+	git clone "super" super-clone &&
+	(
+		cd super-clone &&
+		rm -rf .git/objects/info &&
+		git -c fetch.writeCommitGraph=true fetch origin &&
+		test_path_is_file .git/objects/info/commit-graphs/commit-graph-chain
+	)
+'
+
 # configured prune tests
 
 set_config_tristate () {
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 22 of 23 in “[v2.24.0-rc0 BUG] fetch.writeCommitGraph fails on first fetch”
  1. 0/1 [v2.24.0-rc0 BUG] fetch.writeCommitGraph fails on first fetchDerrick Stolee via GitGitGadget, Oct 22, 2019
  2. 1/1 commit-graph: fix writing first commit-graph during fetchDerrick Stolee via GitGitGadget, Oct 22, 2019
  3. Jeff KingOct 22, 2019
  4. Jeff KingOct 22, 2019
  5. SZEDER GáborOct 22, 2019
  6. Derrick StoleeOct 23, 2019
  7. Jeff KingOct 23, 2019
  8. Jeff KingOct 23, 2019
  9. 0/2 [v2.24.0-rc0 BUG] fetch.writeCommitGraph fails on first fetchDerrick Stolee via GitGitGadget, Oct 23, 2019
  10. 1/2 t5510-fetch.sh: demonstrate fetch.writeCommitGraph bugDerrick Stolee via GitGitGadget, Oct 23, 2019
  11. SZEDER GáborOct 23, 2019
  12. Derrick StoleeOct 23, 2019
  13. SZEDER GáborOct 24, 2019
  14. 2/2 commit-graph: fix writing first commit-graph during fetchDerrick Stolee via GitGitGadget, Oct 23, 2019
  15. SZEDER GáborOct 23, 2019
  16. Derrick StoleeOct 24, 2019
  17. SZEDER GáborOct 30, 2019
  18. 0/2 [v2.24.0-rc0 BUG] fetch.writeCommitGraph fails on first fetchDerrick Stolee via GitGitGadget, Oct 24, 2019
  19. 1/2 t5510-fetch.sh: demonstrate fetch.writeCommitGraph bugDerrick Stolee via GitGitGadget, Oct 24, 2019
  20. 2/2 commit-graph: fix writing first commit-graph during fetchDerrick Stolee via GitGitGadget, Oct 24, 2019
  21. 0/2 [v2.24.0-rc0 BUG] fetch.writeCommitGraph fails on first fetchDerrick Stolee via GitGitGadget, Oct 24, 2019
  22. 1/2 t5510-fetch.sh: demonstrate fetch.writeCommitGraph bugDerrick Stolee via GitGitGadget, Oct 24, 2019
  23. 2/2 commit-graph: fix writing first commit-graph during fetchDerrick Stolee via GitGitGadget, Oct 24, 2019

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.