3 test_description
='sparse checkout tests
5 * (tag: removed, master) removed
7 * (HEAD, tag: top) modified and added
16 test_expect_success
'setup' '
17 cat >expected <<-\EOF &&
18 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
19 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
21 cat >expected.swt <<-\EOF &&
27 echo modified >>init.t &&
30 git add init.t sub/added &&
31 git commit -m "modified and added" &&
34 git commit -m removed &&
37 git ls-files --stage >result &&
38 test_cmp expected result
41 test_expect_success
'read-tree without .git/info/sparse-checkout' '
42 git read-tree -m -u HEAD &&
43 git ls-files --stage >result &&
44 test_cmp expected result &&
45 git ls-files -t >result &&
46 test_cmp expected.swt result
49 test_expect_success
'read-tree with .git/info/sparse-checkout but disabled' '
50 echo >.git/info/sparse-checkout
51 git read-tree -m -u HEAD &&
52 git ls-files -t >result &&
53 test_cmp expected.swt result &&
58 test_expect_success
'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
59 git config core.sparsecheckout true &&
60 echo >.git/info/sparse-checkout &&
61 git read-tree --no-sparse-checkout -m -u HEAD &&
62 git ls-files -t >result &&
63 test_cmp expected.swt result &&
68 test_expect_success
'read-tree with empty .git/info/sparse-checkout' '
69 git config core.sparsecheckout true &&
70 echo >.git/info/sparse-checkout &&
71 test_must_fail git read-tree -m -u HEAD &&
72 git ls-files --stage >result &&
73 test_cmp expected result &&
74 git ls-files -t >result &&
75 test_cmp expected.swt result &&
80 test_expect_success
'match directories with trailing slash' '
81 cat >expected.swt-noinit <<-\EOF &&
86 echo sub/ > .git/info/sparse-checkout &&
87 git read-tree -m -u HEAD &&
88 git ls-files -t > result &&
89 test_cmp expected.swt-noinit result &&
94 test_expect_failure
'match directories without trailing slash' '
95 echo init.t >.git/info/sparse-checkout &&
96 echo sub >>.git/info/sparse-checkout &&
97 git read-tree -m -u HEAD &&
98 git ls-files -t >result &&
99 test_cmp expected.swt result &&
104 test_expect_success
'checkout area changes' '
105 cat >expected.swt-nosub <<-\EOF &&
110 echo init.t >.git/info/sparse-checkout &&
111 git read-tree -m -u HEAD &&
112 git ls-files -t >result &&
113 test_cmp expected.swt-nosub result &&
118 test_expect_success
'read-tree updates worktree, absent case' '
119 echo sub/added >.git/info/sparse-checkout &&
120 git checkout -f top &&
121 git read-tree -m -u HEAD^ &&
125 test_expect_success
'read-tree updates worktree, dirty case' '
126 echo sub/added >.git/info/sparse-checkout &&
127 git checkout -f top &&
128 echo dirty >init.t &&
129 git read-tree -m -u HEAD^ &&
130 grep -q dirty init.t &&
134 test_expect_success
'read-tree removes worktree, dirty case' '
135 echo init.t >.git/info/sparse-checkout &&
136 git checkout -f top &&
138 git read-tree -m -u HEAD^ &&
142 test_expect_success
'read-tree adds to worktree, absent case' '
143 echo init.t >.git/info/sparse-checkout &&
144 git checkout -f removed &&
145 git read-tree -u -m HEAD^ &&
149 test_expect_success
'read-tree adds to worktree, dirty case' '
150 echo init.t >.git/info/sparse-checkout &&
151 git checkout -f removed &&
153 echo dirty >sub/added &&
154 git read-tree -u -m HEAD^ &&
155 grep -q dirty sub/added
158 test_expect_success
'index removal and worktree narrowing at the same time' '
160 echo init.t >.git/info/sparse-checkout &&
161 echo sub/added >>.git/info/sparse-checkout &&
162 git checkout -f top &&
163 echo init.t >.git/info/sparse-checkout &&
164 git checkout removed &&
165 git ls-files sub/added >result &&
166 test ! -f sub/added &&
167 test_cmp empty result
170 test_expect_success
'read-tree --reset removes outside worktree' '
172 echo init.t >.git/info/sparse-checkout &&
173 git checkout -f top &&
174 git reset --hard removed &&
175 git ls-files sub/added >result &&
176 test_cmp empty result