Inter-revision diff: patch 4

Comparing v4 (message) to v9 (message)

--- v4
+++ v9
@@ -1,77 +1,127 @@
 From: Derrick Stolee <dstolee@microsoft.com>
 
-Before moving to update 'git status' and 'git add' to work with sparse
-indexes, add an explicit test that ensures the sparse-index works the
-same as a normal sparse-checkout when the worktree contains directories
-and files outside of the sparse cone.
+As more features integrate with the sparse-index feature, more and more
+special cases arise that require different data shapes within the tree
+structure of the repository in order to demonstrate those cases.
 
-Specifically, 'folder1/a' is a file in our test repo, but 'folder1' is
-not in the sparse cone. When 'folder1/a' is modified, the file is not
-shown as modified and adding it will fail. This is new behavior as of
-a20f704 (add: warn when asked to update SKIP_WORKTREE entries,
-2021-04-08). Before that change, these adds would be silently ignored.
+Add several interesting special cases all at once instead of sprinkling
+them across several commits. The interesting cases being added here are:
 
-Untracked files are fine: adding new files both with 'git add .' and
-'git add folder1/' works just as in a full checkout. This may not be
-entirely desirable, but we are not intending to change behavior at the
-moment, only document it. A future change could alter the behavior to
-be more sensible, and this test could be modified to satisfy the new
-expected behavior.
+* Add sparse-directory entries on both sides of directories within the
+  sparse-checkout definition.
 
+* Add directories outside the sparse-checkout definition who have only
+  one entry and are the first entry of a directory with multiple
+  entries.
+
+* Add filenames adjacent to a sparse directory entry that sort before
+  and after the trailing slash.
+
+Later tests will take advantage of these shapes, but they also deepen
+the tests that already exist.
+
+Reviewed-by: Elijah Newren <newren@gmail.com>
 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
 ---
- t/t1092-sparse-checkout-compatibility.sh | 38 ++++++++++++++++++++++++
- 1 file changed, 38 insertions(+)
+ t/t1092-sparse-checkout-compatibility.sh | 42 ++++++++++++++++++++++--
+ 1 file changed, 40 insertions(+), 2 deletions(-)
 
 diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
-index 98257695979a..fba98d5484ae 100755
+index 87f1014a1c9..0e71a623619 100755
 --- a/t/t1092-sparse-checkout-compatibility.sh
 +++ b/t/t1092-sparse-checkout-compatibility.sh
-@@ -238,6 +238,44 @@ test_expect_success 'add, commit, checkout' '
- 	test_all_match git checkout -
+@@ -17,7 +17,7 @@ test_expect_success 'setup' '
+ 		echo "after folder1" >g &&
+ 		echo "after x" >z &&
+ 		mkdir folder1 folder2 deep x &&
+-		mkdir deep/deeper1 deep/deeper2 &&
++		mkdir deep/deeper1 deep/deeper2 deep/before deep/later &&
+ 		mkdir deep/deeper1/deepest &&
+ 		echo "after deeper1" >deep/e &&
+ 		echo "after deepest" >deep/deeper1/e &&
+@@ -25,10 +25,23 @@ test_expect_success 'setup' '
+ 		cp a folder2 &&
+ 		cp a x &&
+ 		cp a deep &&
++		cp a deep/before &&
+ 		cp a deep/deeper1 &&
+ 		cp a deep/deeper2 &&
++		cp a deep/later &&
+ 		cp a deep/deeper1/deepest &&
+ 		cp -r deep/deeper1/deepest deep/deeper2 &&
++		mkdir deep/deeper1/0 &&
++		mkdir deep/deeper1/0/0 &&
++		touch deep/deeper1/0/1 &&
++		touch deep/deeper1/0/0/0 &&
++		>folder1- &&
++		>folder1.x &&
++		>folder10 &&
++		cp -r deep/deeper1/0 folder1 &&
++		cp -r deep/deeper1/0 folder2 &&
++		echo >>folder1/0/0/0 &&
++		echo >>folder2/0/1 &&
+ 		git add . &&
+ 		git commit -m "initial commit" &&
+ 		git checkout -b base &&
+@@ -56,11 +69,17 @@ test_expect_success 'setup' '
+ 		mv folder1/a folder2/b &&
+ 		mv folder1/larger-content folder2/edited-content &&
+ 		echo >>folder2/edited-content &&
++		echo >>folder2/0/1 &&
++		echo stuff >>deep/deeper1/a &&
+ 		git add . &&
+ 		git commit -m "rename folder1/... to folder2/..." &&
+ 
+ 		git checkout -b rename-out-to-in rename-base &&
+ 		mv folder1/a deep/deeper1/b &&
++		echo more stuff >>deep/deeper1/a &&
++		rm folder2/0/1 &&
++		mkdir folder2/0/1 &&
++		echo >>folder2/0/1/1 &&
+ 		mv folder1/larger-content deep/deeper1/edited-content &&
+ 		echo >>deep/deeper1/edited-content &&
+ 		git add . &&
+@@ -68,6 +87,9 @@ test_expect_success 'setup' '
+ 
+ 		git checkout -b rename-in-to-out rename-base &&
+ 		mv deep/deeper1/a folder1/b &&
++		echo >>folder2/0/1 &&
++		rm -rf folder1/0/0 &&
++		echo >>folder1/0/0 &&
+ 		mv deep/deeper1/larger-content folder1/edited-content &&
+ 		echo >>folder1/edited-content &&
+ 		git add . &&
+@@ -262,13 +284,29 @@ test_expect_success 'diff --staged' '
+ 	test_all_match git diff --staged
  '
  
-+test_expect_success 'status/add: outside sparse cone' '
+-test_expect_success 'diff with renames' '
++test_expect_success 'diff with renames and conflicts' '
+ 	init_repos &&
+ 
+ 	for branch in rename-out-to-out rename-out-to-in rename-in-to-out
+ 	do
+ 		test_all_match git checkout rename-base &&
+ 		test_all_match git checkout $branch -- . &&
++		test_all_match git status --porcelain=v2 &&
++		test_all_match git diff --staged --no-renames &&
++		test_all_match git diff --staged --find-renames || return 1
++	done
++'
++
++test_expect_success 'diff with directory/file conflicts' '
 +	init_repos &&
 +
-+	# adding a "missing" file outside the cone should fail
-+	test_sparse_match test_must_fail git add folder1/a &&
-+
-+	# folder1 is at HEAD, but outside the sparse cone
-+	run_on_sparse mkdir folder1 &&
-+	cp initial-repo/folder1/a sparse-checkout/folder1/a &&
-+	cp initial-repo/folder1/a sparse-index/folder1/a &&
-+
-+	test_sparse_match git status &&
-+
-+	write_script edit-contents <<-\EOF &&
-+	echo text >>$1
-+	EOF
-+	run_on_sparse ../edit-contents folder1/a &&
-+	run_on_all ../edit-contents folder1/new &&
-+
-+	test_sparse_match git status --porcelain=v2 &&
-+
-+	# This "git add folder1/a" fails with a warning
-+	# in the sparse repos, differing from the full
-+	# repo. This is intentional.
-+	test_sparse_match test_must_fail git add folder1/a &&
-+	test_sparse_match test_must_fail git add --refresh folder1/a &&
-+	test_all_match git status --porcelain=v2 &&
-+
-+	test_all_match git add . &&
-+	test_all_match git status --porcelain=v2 &&
-+	test_all_match git commit -m folder1/new &&
-+
-+	run_on_all ../edit-contents folder1/newer &&
-+	test_all_match git add folder1/ &&
-+	test_all_match git status --porcelain=v2 &&
-+	test_all_match git commit -m folder1/newer
-+'
-+
- test_expect_success 'checkout and reset --hard' '
- 	init_repos &&
- 
++	for branch in rename-out-to-out rename-out-to-in rename-in-to-out
++	do
++		git -C full-checkout reset --hard &&
++		test_sparse_match git reset --hard &&
++		test_all_match git checkout $branch &&
++		test_all_match git checkout rename-base -- . &&
++		test_all_match git status --porcelain=v2 &&
+ 		test_all_match git diff --staged --no-renames &&
+ 		test_all_match git diff --staged --find-renames || return 1
+ 	done
 -- 
 gitgitgadget
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help