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

[PATCH v4 01/10] t7519: rewrite sparse index test

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 24, 2021, 21:51 UTC
Message-ID
<c407b2cb346b32cdf95c6017d16b93dd1483c627.1629841904.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1009.v4.git.1629841904.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

The sparse index is tested with the FS Monitor hook and extension since f8fe49e (fsmonitor: integrate with sparse index, 2021-07-14). This test was very fragile because it shared an index across sparse and non-sparse behavior. Since that expansion and contraction could cause the index to lose its FS Monitor bitmap and token, behavior is fragile to changes in 'git sparse-checkout set'.

Rewrite the test to use two clones of the original repo: full and sparse. This allows us to also keep the test files (actual, expect, trace2.txt) out of the repos we are testing with 'git status'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 t/t7519-status-fsmonitor.sh | 38 ++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh
index deea88d4431..f1463197b99 100755
--- a/t/t7519-status-fsmonitor.sh
+++ b/t/t7519-status-fsmonitor.sh
@@ -389,43 +389,47 @@ test_expect_success 'status succeeds after staging/unstaging' '
 # If "!" is supplied, then we verify that we do not call ensure_full_index
 # during a call to 'git status'. Otherwise, we verify that we _do_ call it.
 check_sparse_index_behavior () {
-	git status --porcelain=v2 >expect &&
-	git sparse-checkout init --cone --sparse-index &&
-	git sparse-checkout set dir1 dir2 &&
+	git -C full status --porcelain=v2 >expect &&
 	GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
-		git status --porcelain=v2 >actual &&
+		git -C sparse status --porcelain=v2 >actual &&
 	test_region $1 index ensure_full_index trace2.txt &&
 	test_region fsm_hook query trace2.txt &&
 	test_cmp expect actual &&
-	rm trace2.txt &&
-	git sparse-checkout disable
+	rm trace2.txt
 }
 
 test_expect_success 'status succeeds with sparse index' '
-	git reset --hard &&
+	git clone . full &&
+	git clone --sparse . sparse &&
+	git -C sparse sparse-checkout init --cone --sparse-index &&
+	git -C sparse sparse-checkout set dir1 dir2 &&
 
-	test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
-	check_sparse_index_behavior ! &&
-
-	write_script .git/hooks/fsmonitor-test<<-\EOF &&
+	write_script .git/hooks/fsmonitor-test <<-\EOF &&
 		printf "last_update_token\0"
 	EOF
-	git config core.fsmonitor .git/hooks/fsmonitor-test &&
+	git -C full config core.fsmonitor ../.git/hooks/fsmonitor-test &&
+	git -C sparse config core.fsmonitor ../.git/hooks/fsmonitor-test &&
 	check_sparse_index_behavior ! &&
 
-	write_script .git/hooks/fsmonitor-test<<-\EOF &&
+	write_script .git/hooks/fsmonitor-test <<-\EOF &&
 		printf "last_update_token\0"
 		printf "dir1/modified\0"
 	EOF
 	check_sparse_index_behavior ! &&
 
-	cp -r dir1 dir1a &&
-	git add dir1a &&
-	git commit -m "add dir1a" &&
+	git -C sparse sparse-checkout add dir1a &&
+
+	for repo in full sparse
+	do
+		cp -r $repo/dir1 $repo/dir1a &&
+		git -C $repo add dir1a &&
+		git -C $repo commit -m "add dir1a" || return 1
+	done &&
+	git -C sparse sparse-checkout set dir1 dir2 &&
 
 	# This one modifies outside the sparse-checkout definition
 	# and hence we expect to expand the sparse-index.
-	write_script .git/hooks/fsmonitor-test<<-\EOF &&
+	write_script .git/hooks/fsmonitor-test <<-\EOF &&
 		printf "last_update_token\0"
 		printf "dir1a/modified\0"
 	EOF
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 54 of 92 in “Sparse index: delete ignored files outside sparse cone”
  1. 0/2 Sparse index: delete ignored files outside sparse coneDerrick Stolee via GitGitGadget, Jul 29, 2021
  2. 1/2 t7519: rewrite sparse index testDerrick Stolee via GitGitGadget, Jul 29, 2021
  3. 2/2 sparse-checkout: clear tracked sparse dirsDerrick Stolee via GitGitGadget, Jul 29, 2021
  4. Elijah NewrenJul 30, 2021
  5. Derrick StoleeAug 2, 2021
  6. Elijah NewrenAug 2, 2021
  7. Derrick StoleeAug 5, 2021
  8. Elijah NewrenAug 5, 2021
  9. Elijah NewrenJul 30, 2021
  10. 0/8 Sparse index: delete ignored files outside sparse coneDerrick Stolee via GitGitGadget, Aug 10, 2021
  11. 1/8 t7519: rewrite sparse index testDerrick Stolee via GitGitGadget, Aug 10, 2021
  12. 2/8 sparse-index: silently return when not using cone-mode patternsDerrick Stolee via GitGitGadget, Aug 10, 2021
  13. 3/8 sparse-index: silently return when cache tree failsDerrick Stolee via GitGitGadget, Aug 10, 2021
  14. Elijah NewrenAug 19, 2021
  15. Derrick StoleeAug 20, 2021
  16. 4/8 unpack-trees: fix nested sparse-dir searchDerrick Stolee via GitGitGadget, Aug 10, 2021
  17. 5/8 sparse-checkout: create helper methodsDerrick Stolee via GitGitGadget, Aug 10, 2021
  18. Derrick StoleeAug 12, 2021
  19. 6/8 attr: be careful about sparse directoriesDerrick Stolee via GitGitGadget, Aug 10, 2021
  20. 7/8 sparse-index: add SPARSE_INDEX_IGNORE_CONFIG flagDerrick Stolee via GitGitGadget, Aug 10, 2021
  21. 8/8 sparse-checkout: clear tracked sparse dirsDerrick Stolee via GitGitGadget, Aug 10, 2021
  22. 0/8 Sparse index: delete ignored files outside sparse coneDerrick Stolee via GitGitGadget, Aug 17, 2021
  23. 2/8 sparse-index: silently return when not using cone-mode patternsDerrick Stolee via GitGitGadget, Aug 17, 2021
  24. 1/8 t7519: rewrite sparse index testDerrick Stolee via GitGitGadget, Aug 17, 2021
  25. Johannes SchindelinAug 19, 2021
  26. Derrick StoleeAug 20, 2021
  27. Eric SunshineAug 20, 2021
  28. 3/8 sparse-index: silently return when cache tree failsDerrick Stolee via GitGitGadget, Aug 17, 2021
  29. 5/8 sparse-checkout: create helper methodsDerrick Stolee via GitGitGadget, Aug 17, 2021
  30. Johannes SchindelinAug 19, 2021
  31. Derrick StoleeAug 20, 2021
  32. 4/8 unpack-trees: fix nested sparse-dir searchDerrick Stolee via GitGitGadget, Aug 17, 2021
  33. Johannes SchindelinAug 19, 2021
  34. Derrick StoleeAug 20, 2021
  35. René ScharfeAug 20, 2021
  36. René ScharfeAug 20, 2021
  37. Elijah NewrenAug 19, 2021
  38. 8/8 sparse-checkout: clear tracked sparse dirsDerrick Stolee via GitGitGadget, Aug 17, 2021
  39. Johannes SchindelinAug 19, 2021
  40. Derrick StoleeAug 20, 2021
  41. Elijah NewrenAug 20, 2021
  42. Elijah NewrenAug 20, 2021
  43. Johannes SchindelinAug 23, 2021
  44. 7/8 sparse-index: add SPARSE_INDEX_IGNORE_CONFIG flagDerrick Stolee via GitGitGadget, Aug 17, 2021
  45. Derrick StoleeAug 18, 2021
  46. 6/8 attr: be careful about sparse directoriesDerrick Stolee via GitGitGadget, Aug 17, 2021
  47. Johannes SchindelinAug 19, 2021
  48. Derrick StoleeAug 20, 2021
  49. Elijah NewrenAug 19, 2021
  50. Derrick StoleeAug 20, 2021
  51. Elijah NewrenAug 20, 2021
  52. Elijah NewrenAug 17, 2021
  53. 00/10 Sparse index: delete ignored files outside sparse coneDerrick Stolee via GitGitGadget, Aug 24, 2021
  54. 01/10 t7519: rewrite sparse index testDerrick Stolee via GitGitGadget, Aug 24, 2021
  55. 02/10 sparse-index: silently return when not using cone-mode patternsDerrick Stolee via GitGitGadget, Aug 24, 2021
  56. 03/10 sparse-index: silently return when cache tree failsDerrick Stolee via GitGitGadget, Aug 24, 2021
  57. 04/10 sparse-index: use WRITE_TREE_MISSING_OKDerrick Stolee via GitGitGadget, Aug 24, 2021
  58. Elijah NewrenAug 27, 2021
  59. Derrick StoleeAug 30, 2021
  60. Elijah NewrenAug 30, 2021
  61. 05/10 unpack-trees: fix nested sparse-dir searchDerrick Stolee via GitGitGadget, Aug 24, 2021
  62. René ScharfeAug 24, 2021
  63. Derrick StoleeAug 25, 2021
  64. 06/10 sparse-checkout: create helper methodsDerrick Stolee via GitGitGadget, Aug 24, 2021
  65. 07/10 attr: be careful about sparse directoriesDerrick Stolee via GitGitGadget, Aug 24, 2021
  66. 08/10 sparse-index: add SPARSE_INDEX_MEMORY_ONLY flagDerrick Stolee via GitGitGadget, Aug 24, 2021
  67. 09/10 sparse-checkout: clear tracked sparse dirsDerrick Stolee via GitGitGadget, Aug 24, 2021
  68. 10/10 sparse-checkout: add config to disable deleting dirsDerrick Stolee via GitGitGadget, Aug 24, 2021
  69. Elijah NewrenAug 27, 2021
  70. Derrick StoleeAug 30, 2021
  71. Elijah NewrenAug 30, 2021
  72. Elijah NewrenAug 27, 2021
  73. Elijah NewrenAug 27, 2021
  74. Derrick StoleeAug 30, 2021
  75. Elijah NewrenAug 30, 2021
  76. Derrick StoleeAug 30, 2021
  77. Elijah NewrenAug 30, 2021
  78. 0/9 Sparse index: delete ignored files outside sparse coneDerrick Stolee via GitGitGadget, Sep 8, 2021
  79. 1/9 t7519: rewrite sparse index testDerrick Stolee via GitGitGadget, Sep 8, 2021
  80. 2/9 sparse-index: silently return when not using cone-mode patternsDerrick Stolee via GitGitGadget, Sep 8, 2021
  81. 3/9 unpack-trees: fix nested sparse-dir searchDerrick Stolee via GitGitGadget, Sep 8, 2021
  82. 5/9 sparse-index: use WRITE_TREE_MISSING_OKDerrick Stolee via GitGitGadget, Sep 8, 2021
  83. 4/9 sparse-index: silently return when cache tree failsDerrick Stolee via GitGitGadget, Sep 8, 2021
  84. 6/9 sparse-checkout: create helper methodsDerrick Stolee via GitGitGadget, Sep 8, 2021
  85. 7/9 attr: be careful about sparse directoriesDerrick Stolee via GitGitGadget, Sep 8, 2021
  86. 8/9 sparse-index: add SPARSE_INDEX_MEMORY_ONLY flagDerrick Stolee via GitGitGadget, Sep 8, 2021
  87. 9/9 sparse-checkout: clear tracked sparse dirsDerrick Stolee via GitGitGadget, Sep 8, 2021
  88. Junio C HamanoSep 8, 2021
  89. Junio C HamanoSep 8, 2021
  90. Derrick StoleeSep 8, 2021
  91. Junio C HamanoSep 8, 2021
  92. Elijah NewrenSep 8, 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.