Inter-revision diff: patch 4

Comparing v2 (message) to v6 (message)

--- v2
+++ v6
@@ -1,60 +1,120 @@
 From: Derrick Stolee <dstolee@microsoft.com>
 
-When walking trees using traverse_trees_recursive() and
-unpack_callback(), we must not attempt to walk into a sparse directory
-entry. There are no index entries within that directory to compare to
-the tree object at that position, so skip over the entries of that tree.
+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.
 
-This code is used in many places, so the only way to test it is to start
-removing the command_requres_full_index option from one builtin at a
-time and carefully test that its use of unpack_trees() behaves correctly
-with a sparse-index. Such tests will be added by later changes.
+Add several interesting special cases all at once instead of sprinkling
+them across several commits. The interesting cases being added here are:
+
+* 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.
+
+Later tests will take advantage of these shapes, but they also deepen
+the tests that already exist.
 
 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
 ---
- unpack-trees.c | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
+ t/t1092-sparse-checkout-compatibility.sh | 39 ++++++++++++++++++++++--
+ 1 file changed, 37 insertions(+), 2 deletions(-)
 
-diff --git a/unpack-trees.c b/unpack-trees.c
-index 3af797093095..67777570f829 100644
---- a/unpack-trees.c
-+++ b/unpack-trees.c
-@@ -1256,6 +1256,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
- 	struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
- 	struct unpack_trees_options *o = info->data;
- 	const struct name_entry *p = names;
-+	unsigned unpack_tree = 1;
+diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
+index ebbba044f77..4a7b48e8d3f 100755
+--- a/t/t1092-sparse-checkout-compatibility.sh
++++ b/t/t1092-sparse-checkout-compatibility.sh
+@@ -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,20 @@ 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 &&
++		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 +66,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/..." &&
  
- 	/* Find first entry with a real name (we could use "mask" too) */
- 	while (!p->mode)
-@@ -1297,12 +1298,16 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
- 					}
- 				}
- 				src[0] = ce;
+ 		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 +84,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 +281,29 @@ test_expect_success 'diff --staged' '
+ 	test_all_match git diff --staged
+ '
+ 
+-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
++'
 +
-+				if (S_ISSPARSEDIR(ce->ce_mode))
-+					unpack_tree = 0;
- 			}
- 			break;
- 		}
- 	}
- 
--	if (unpack_nondirectories(n, mask, dirmask, src, names, info) < 0)
-+	if (unpack_tree &&
-+	    unpack_nondirectories(n, mask, dirmask, src, names, info) < 0)
- 		return -1;
- 
- 	if (o->merge && src[0]) {
-@@ -1332,7 +1337,8 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
- 			}
- 		}
- 
--		if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
-+		if (unpack_tree &&
-+		    traverse_trees_recursive(n, dirmask, mask & ~dirmask,
- 					     names, info) < 0)
- 			return -1;
- 		return mask;
++test_expect_success 'diff with directory/file conflicts' '
++	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