--- v3
+++ v1
@@ -15,10 +15,10 @@
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
- Documentation/git-ls-files.txt | 4 +
- builtin/ls-files.c | 12 ++-
- t/t1092-sparse-checkout-compatibility.sh | 96 ++++++++++++++++++++++++
- 3 files changed, 110 insertions(+), 2 deletions(-)
+ Documentation/git-ls-files.txt | 4 ++
+ builtin/ls-files.c | 12 +++++-
+ t/t1092-sparse-checkout-compatibility.sh | 47 ++++++++++++++++++++++++
+ 3 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 6d11ab506b7..1c5d5f85ec5 100644
@@ -80,10 +80,10 @@
if (prefix)
prefix_len = strlen(prefix);
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
-index 3ba19ba1c14..29b97667378 100755
+index f8a8dde60af..ffb6052ff60 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
-@@ -802,6 +802,12 @@ test_expect_success 'sparse-index is expanded and converted back' '
+@@ -814,6 +814,12 @@ test_expect_success 'sparse-index is expanded and converted back' '
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
git -C sparse-index reset -- folder1/a &&
test_region index convert_to_sparse trace2.txt &&
@@ -96,7 +96,7 @@
test_region index ensure_full_index trace2.txt
'
-@@ -826,6 +832,7 @@ test_expect_success 'sparse-index is not expanded' '
+@@ -838,6 +844,7 @@ test_expect_success 'sparse-index is not expanded' '
init_repos &&
ensure_not_expanded status &&
@@ -104,7 +104,7 @@
ensure_not_expanded commit --allow-empty -m empty &&
echo >>sparse-index/a &&
ensure_not_expanded commit -a -m a &&
-@@ -974,6 +981,95 @@ test_expect_success 'sparse index is not expanded: fetch/pull' '
+@@ -942,6 +949,46 @@ test_expect_success 'sparse index is not expanded: fetch/pull' '
ensure_not_expanded pull full base
'
@@ -115,51 +115,23 @@
+ test_all_match git ls-files &&
+
+ # With --sparse, the sparse index data changes behavior.
-+ git -C sparse-index ls-files >dense &&
-+ git -C sparse-index ls-files --sparse >sparse &&
-+
-+ cat >expect <<-\EOF &&
-+ @@ -13,13 +13,9 @@
-+ e
-+ folder1-
-+ folder1.x
-+ -folder1/0/0/0
-+ -folder1/0/1
-+ -folder1/a
-+ +folder1/
-+ folder10
-+ -folder2/0/0/0
-+ -folder2/0/1
-+ -folder2/a
-+ +folder2/
-+ g
-+ -x/a
-+ +x/
-+ z
-+ EOF
-+
-+ diff -u dense sparse | tail -n +3 >actual &&
-+ test_cmp expect actual &&
++ git -C sparse-index ls-files --sparse >sparse-index-out &&
++ grep "^folder1/\$" sparse-index-out &&
++ grep "^folder2/\$" sparse-index-out &&
+
+ # With --sparse and no sparse index, nothing changes.
-+ git -C sparse-checkout ls-files >dense &&
-+ git -C sparse-checkout ls-files --sparse >sparse &&
-+ test_cmp dense sparse &&
++ git -C sparse-checkout ls-files --sparse >sparse-checkout-out &&
++ grep "^folder1/0/0/0\$" sparse-checkout-out &&
++ ! grep "/\$" sparse-checkout-out &&
+
-+ # Set up a strange condition of having a file edit
-+ # outside of the sparse-checkout cone. This is just
-+ # to verify that sparse-checkout and sparse-index
-+ # behave the same in this case.
+ write_script edit-content <<-\EOF &&
+ mkdir folder1 &&
+ echo content >>folder1/a
+ EOF
+ run_on_sparse ../edit-content &&
+
-+ # ls-files does not currently notice modified files whose
-+ # cache entries are marked SKIP_WORKTREE. This may change
-+ # in the future, but here we test that sparse index does
-+ # not accidentally create a change of behavior.
++ # ls-files does not notice modified files whose
++ # cache entries are marked SKIP_WORKTREE.
+ test_sparse_match git ls-files --modified &&
+ test_must_be_empty sparse-checkout-out &&
+ test_must_be_empty sparse-index-out &&
@@ -167,33 +139,12 @@
+ git -C sparse-index ls-files --sparse --modified >sparse-index-out &&
+ test_must_be_empty sparse-index-out &&
+
-+ # Add folder1 to the sparse-checkout cone and
-+ # check that ls-files shows the expanded files.
-+ test_sparse_match git sparse-checkout add folder1 &&
++ run_on_sparse git sparse-checkout add folder1 &&
+ test_sparse_match git ls-files --modified &&
++ grep "^folder1/a\$" sparse-checkout-out &&
++ grep "^folder1/a\$" sparse-index-out &&
+
-+ git -C sparse-index ls-files >dense &&
-+ git -C sparse-index ls-files --sparse >sparse &&
-+
-+ cat >expect <<-\EOF &&
-+ @@ -17,9 +17,7 @@
-+ folder1/0/1
-+ folder1/a
-+ folder10
-+ -folder2/0/0/0
-+ -folder2/0/1
-+ -folder2/a
-+ +folder2/
-+ g
-+ -x/a
-+ +x/
-+ z
-+ EOF
-+
-+ diff -u dense sparse | tail -n +3 >actual &&
-+ test_cmp expect actual &&
-+
-+ # Double-check index expansion is avoided
++ # Double-check index expansion
+ ensure_not_expanded ls-files --sparse
+'
+
@@ -202,4 +153,3 @@
test_expect_success 'reset mixed and checkout orphan' '
--
gitgitgadget
-