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_failure 'match directories without trailing slash' '
98 echo init.t >.git/info/sparse-checkout &&
99 echo sub >>.git/info/sparse-checkout &&
100 git read-tree -m -u HEAD &&
101 git ls-files -t >result &&
102 test_cmp expected.swt result &&
107 test_expect_success 'checkout area changes' '
108 cat >expected.swt-nosub <<-\EOF &&
114 echo init.t >.git/info/sparse-checkout &&
115 git read-tree -m -u HEAD &&
116 git ls-files -t >result &&
117 test_cmp expected.swt-nosub result &&
122 test_expect_success 'read-tree updates worktree, absent case' '
123 echo sub/added >.git/info/sparse-checkout &&
124 git checkout -f top &&
125 git read-tree -m -u HEAD^ &&
129 test_expect_success 'read-tree updates worktree, dirty case' '
130 echo sub/added >.git/info/sparse-checkout &&
131 git checkout -f top &&
132 echo dirty >init.t &&
133 git read-tree -m -u HEAD^ &&
134 grep -q dirty init.t &&
138 test_expect_success 'read-tree removes worktree, dirty case' '
139 echo init.t >.git/info/sparse-checkout &&
140 git checkout -f top &&
142 git read-tree -m -u HEAD^ &&
146 test_expect_success 'read-tree adds to worktree, absent case' '
147 echo init.t >.git/info/sparse-checkout &&
148 git checkout -f removed &&
149 git read-tree -u -m HEAD^ &&
153 test_expect_success 'read-tree adds to worktree, dirty case' '
154 echo init.t >.git/info/sparse-checkout &&
155 git checkout -f removed &&
157 echo dirty >sub/added &&
158 git read-tree -u -m HEAD^ &&
159 grep -q dirty sub/added
162 test_expect_success 'index removal and worktree narrowing at the same time' '
164 echo init.t >.git/info/sparse-checkout &&
165 echo sub/added >>.git/info/sparse-checkout &&
166 git checkout -f top &&
167 echo init.t >.git/info/sparse-checkout &&
168 git checkout removed &&
169 git ls-files sub/added >result &&
170 test ! -f sub/added &&
171 test_cmp empty result
174 test_expect_success 'read-tree --reset removes outside worktree' '
176 echo init.t >.git/info/sparse-checkout &&
177 git checkout -f top &&
178 git reset --hard removed &&
179 git ls-files sub/added >result &&
180 test_cmp empty result