Merge branch 'tr/xsize-bits' into maint
[tgit.git] / t / t1011-read-tree-sparse-checkout.sh
blob62246dbf9546b9ee5ad4dbeb0b34de45a1671ac2
1 #!/bin/sh
3 test_description='sparse checkout tests'
5 . ./test-lib.sh
7 cat >expected <<EOF
8 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
9 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
10 EOF
11 test_expect_success 'setup' '
12 test_commit init &&
13 echo modified >> init.t &&
14 mkdir sub &&
15 touch sub/added &&
16 git add init.t sub/added &&
17 git commit -m "modified and added" &&
18 git tag top &&
19 git rm sub/added &&
20 git commit -m removed &&
21 git tag removed &&
22 git checkout top &&
23 git ls-files --stage > result &&
24 test_cmp expected result
27 cat >expected.swt <<EOF
28 H init.t
29 H sub/added
30 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 &&
44 test -f init.t &&
45 test -f sub/added
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 &&
54 test -f init.t &&
55 test -f sub/added
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 &&
66 test -f init.t &&
67 test -f sub/added
70 cat >expected.swt <<EOF
71 S init.t
72 H sub/added
73 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 &&
79 test ! -f init.t &&
80 test -f sub/added
83 cat >expected.swt <<EOF
84 H init.t
85 H sub/added
86 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 &&
93 test ! -f init.t &&
94 test -f sub/added
97 cat >expected.swt <<EOF
98 H init.t
99 S sub/added
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 &&
106 test -f init.t &&
107 test ! -f sub/added
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^ &&
114 test ! -f init.t
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 &&
123 rm 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^ &&
131 grep -q dirty added
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^ &&
138 test ! -f sub/added
141 test_expect_success 'read-tree adds to worktree, dirty case' '
142 echo init.t > .git/info/sparse-checkout &&
143 git checkout -f removed &&
144 mkdir sub &&
145 echo dirty > sub/added &&
146 git read-tree -u -m HEAD^ &&
147 grep -q dirty sub/added
150 test_done