3 test_description='sparse checkout tests'
8 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
9 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
11 test_expect_success 'setup' '
13 echo modified >> init.t &&
16 git add init.t sub/added &&
17 git commit -m "modified and added" &&
20 git commit -m removed &&
23 git ls-files --stage > result &&
24 test_cmp expected result
27 cat >expected.swt <<EOF
31 test_expect_success 'read-tree without .git/info/sparse-checkout' '
32 git read-tree -m -u HEAD &&
33 git ls-files --stage > result &&
34 test_cmp expected result &&
35 git ls-files -t > result &&
36 test_cmp expected.swt result
39 test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
40 echo > .git/info/sparse-checkout
41 git read-tree -m -u HEAD &&
42 git ls-files -t > result &&
43 test_cmp expected.swt result &&
48 test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
49 git config core.sparsecheckout true &&
50 echo > .git/info/sparse-checkout &&
51 git read-tree --no-sparse-checkout -m -u HEAD &&
52 git ls-files -t > result &&
53 test_cmp expected.swt result &&
58 test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
59 git config core.sparsecheckout true &&
60 echo > .git/info/sparse-checkout &&
61 test_must_fail git read-tree -m -u HEAD &&
62 git ls-files --stage > result &&
63 test_cmp expected result &&
64 git ls-files -t > result &&
65 test_cmp expected.swt result &&
70 cat >expected.swt <<EOF
74 test_expect_success 'match directories with trailing slash' '
75 echo sub/ > .git/info/sparse-checkout &&
76 git read-tree -m -u HEAD &&
77 git ls-files -t > result &&
78 test_cmp expected.swt result &&
83 cat >expected.swt <<EOF
87 test_expect_failure 'match directories without trailing slash' '
88 echo init.t > .git/info/sparse-checkout &&
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 result &&
97 cat >expected.swt <<EOF
101 test_expect_success 'checkout area changes' '
102 echo init.t > .git/info/sparse-checkout &&
103 git read-tree -m -u HEAD &&
104 git ls-files -t > result &&
105 test_cmp expected.swt result &&
110 test_expect_success 'read-tree updates worktree, absent case' '
111 echo sub/added > .git/info/sparse-checkout &&
112 git checkout -f top &&
113 git read-tree -m -u HEAD^ &&
117 test_expect_success 'read-tree updates worktree, dirty case' '
118 echo sub/added > .git/info/sparse-checkout &&
119 git checkout -f top &&
120 echo dirty > init.t &&
121 git read-tree -m -u HEAD^ &&
122 grep -q dirty init.t &&
126 test_expect_success 'read-tree removes worktree, dirty case' '
127 echo init.t > .git/info/sparse-checkout &&
128 git checkout -f top &&
129 echo dirty > added &&
130 git read-tree -m -u HEAD^ &&
134 test_expect_success 'read-tree adds to worktree, absent case' '
135 echo init.t > .git/info/sparse-checkout &&
136 git checkout -f removed &&
137 git read-tree -u -m HEAD^ &&
141 test_expect_success 'read-tree adds to worktree, dirty case' '
142 echo init.t > .git/info/sparse-checkout &&
143 git checkout -f removed &&
145 echo dirty > sub/added &&
146 git read-tree -u -m HEAD^ &&
147 grep -q dirty sub/added