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
20 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
22 cat >expected.swt <<-\EOF &&
29 echo modified >>init.t &&
31 touch sub/added subsub/added &&
32 git add init.t sub/added subsub/added &&
33 git commit -m "modified and added" &&
36 git commit -m removed &&
39 git ls-files --stage >result &&
40 test_cmp expected result
43 test_expect_success
'read-tree without .git/info/sparse-checkout' '
44 git read-tree -m -u HEAD &&
45 git ls-files --stage >result &&
46 test_cmp expected result &&
47 git ls-files -t >result &&
48 test_cmp expected.swt result
51 test_expect_success
'read-tree with .git/info/sparse-checkout but disabled' '
52 echo >.git/info/sparse-checkout &&
53 git read-tree -m -u HEAD &&
54 git ls-files -t >result &&
55 test_cmp expected.swt result &&
60 test_expect_success
'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
61 git config core.sparsecheckout true &&
62 echo >.git/info/sparse-checkout &&
63 git read-tree --no-sparse-checkout -m -u HEAD &&
64 git ls-files -t >result &&
65 test_cmp expected.swt result &&
70 test_expect_success
'read-tree with empty .git/info/sparse-checkout' '
71 git config core.sparsecheckout true &&
72 echo >.git/info/sparse-checkout &&
73 test_must_fail git read-tree -m -u HEAD &&
74 git ls-files --stage >result &&
75 test_cmp expected result &&
76 git ls-files -t >result &&
77 test_cmp expected.swt result &&
82 test_expect_success
'match directories with trailing slash' '
83 cat >expected.swt-noinit <<-\EOF &&
89 echo sub/ > .git/info/sparse-checkout &&
90 git read-tree -m -u HEAD &&
91 git ls-files -t > result &&
92 test_cmp expected.swt-noinit result &&
97 test_expect_success
'match directories without trailing slash' '
98 echo sub >>.git/info/sparse-checkout &&
99 git read-tree -m -u HEAD &&
100 git ls-files -t >result &&
101 test_cmp expected.swt-noinit result &&
106 test_expect_success
'match directory pattern' '
107 echo "s?b" >>.git/info/sparse-checkout &&
108 git read-tree -m -u HEAD &&
109 git ls-files -t >result &&
110 test_cmp expected.swt-noinit result &&
115 test_expect_success
'checkout area changes' '
116 cat >expected.swt-nosub <<-\EOF &&
122 echo init.t >.git/info/sparse-checkout &&
123 git read-tree -m -u HEAD &&
124 git ls-files -t >result &&
125 test_cmp expected.swt-nosub result &&
130 test_expect_success
'read-tree updates worktree, absent case' '
131 echo sub/added >.git/info/sparse-checkout &&
132 git checkout -f top &&
133 git read-tree -m -u HEAD^ &&
137 test_expect_success
'read-tree updates worktree, dirty case' '
138 echo sub/added >.git/info/sparse-checkout &&
139 git checkout -f top &&
140 echo dirty >init.t &&
141 git read-tree -m -u HEAD^ &&
142 grep -q dirty init.t &&
146 test_expect_success
'read-tree removes worktree, dirty case' '
147 echo init.t >.git/info/sparse-checkout &&
148 git checkout -f top &&
150 git read-tree -m -u HEAD^ &&
154 test_expect_success
'read-tree adds to worktree, absent case' '
155 echo init.t >.git/info/sparse-checkout &&
156 git checkout -f removed &&
157 git read-tree -u -m HEAD^ &&
161 test_expect_success
'read-tree adds to worktree, dirty case' '
162 echo init.t >.git/info/sparse-checkout &&
163 git checkout -f removed &&
165 echo dirty >sub/added &&
166 git read-tree -u -m HEAD^ &&
167 grep -q dirty sub/added
170 test_expect_success
'index removal and worktree narrowing at the same time' '
172 echo init.t >.git/info/sparse-checkout &&
173 echo sub/added >>.git/info/sparse-checkout &&
174 git checkout -f top &&
175 echo init.t >.git/info/sparse-checkout &&
176 git checkout removed &&
177 git ls-files sub/added >result &&
178 test ! -f sub/added &&
179 test_cmp empty result
182 test_expect_success
'read-tree --reset removes outside worktree' '
184 echo init.t >.git/info/sparse-checkout &&
185 git checkout -f top &&
186 git reset --hard removed &&
187 git ls-files sub/added >result &&
188 test_cmp empty result