]>
Commit | Line | Data |
---|---|---|
d6b38f61 NTND |
1 | #!/bin/sh |
2 | ||
7f71a6ae JN |
3 | test_description='sparse checkout tests |
4 | ||
5 | * (tag: removed, master) removed | |
6 | | D sub/added | |
7 | * (HEAD, tag: top) modified and added | |
8 | | M init.t | |
9 | | A sub/added | |
10 | * (tag: init) init | |
11 | A init.t | |
12 | ' | |
d6b38f61 NTND |
13 | |
14 | . ./test-lib.sh | |
15 | ||
d6b38f61 | 16 | test_expect_success 'setup' ' |
7f71a6ae JN |
17 | cat >expected <<-\EOF && |
18 | 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t | |
19 | 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added | |
ae3cdfe1 | 20 | 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added |
7f71a6ae JN |
21 | EOF |
22 | cat >expected.swt <<-\EOF && | |
23 | H init.t | |
24 | H sub/added | |
ae3cdfe1 | 25 | H subsub/added |
7f71a6ae JN |
26 | EOF |
27 | ||
d6b38f61 | 28 | test_commit init && |
7f71a6ae | 29 | echo modified >>init.t && |
ae3cdfe1 NTND |
30 | mkdir sub subsub && |
31 | touch sub/added subsub/added && | |
32 | git add init.t sub/added subsub/added && | |
d6b38f61 NTND |
33 | git commit -m "modified and added" && |
34 | git tag top && | |
35 | git rm sub/added && | |
36 | git commit -m removed && | |
37 | git tag removed && | |
38 | git checkout top && | |
7f71a6ae | 39 | git ls-files --stage >result && |
d6b38f61 NTND |
40 | test_cmp expected result |
41 | ' | |
42 | ||
d6b38f61 NTND |
43 | test_expect_success 'read-tree without .git/info/sparse-checkout' ' |
44 | git read-tree -m -u HEAD && | |
7f71a6ae | 45 | git ls-files --stage >result && |
d6b38f61 | 46 | test_cmp expected result && |
7f71a6ae | 47 | git ls-files -t >result && |
d6b38f61 NTND |
48 | test_cmp expected.swt result |
49 | ' | |
50 | ||
51 | test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' ' | |
a48fcd83 | 52 | echo >.git/info/sparse-checkout && |
d6b38f61 | 53 | git read-tree -m -u HEAD && |
7f71a6ae | 54 | git ls-files -t >result && |
d6b38f61 NTND |
55 | test_cmp expected.swt result && |
56 | test -f init.t && | |
57 | test -f sub/added | |
58 | ' | |
59 | ||
60 | test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' ' | |
61 | git config core.sparsecheckout true && | |
7f71a6ae | 62 | echo >.git/info/sparse-checkout && |
d6b38f61 | 63 | git read-tree --no-sparse-checkout -m -u HEAD && |
7f71a6ae | 64 | git ls-files -t >result && |
d6b38f61 NTND |
65 | test_cmp expected.swt result && |
66 | test -f init.t && | |
67 | test -f sub/added | |
68 | ' | |
69 | ||
d6b38f61 NTND |
70 | test_expect_success 'read-tree with empty .git/info/sparse-checkout' ' |
71 | git config core.sparsecheckout true && | |
7f71a6ae | 72 | echo >.git/info/sparse-checkout && |
9e1afb16 | 73 | test_must_fail git read-tree -m -u HEAD && |
7f71a6ae | 74 | git ls-files --stage >result && |
d6b38f61 | 75 | test_cmp expected result && |
7f71a6ae | 76 | git ls-files -t >result && |
d6b38f61 | 77 | test_cmp expected.swt result && |
9e1afb16 NTND |
78 | test -f init.t && |
79 | test -f sub/added | |
d6b38f61 NTND |
80 | ' |
81 | ||
d6b38f61 | 82 | test_expect_success 'match directories with trailing slash' ' |
7f71a6ae JN |
83 | cat >expected.swt-noinit <<-\EOF && |
84 | S init.t | |
85 | H sub/added | |
ae3cdfe1 | 86 | S subsub/added |
7f71a6ae JN |
87 | EOF |
88 | ||
d6b38f61 NTND |
89 | echo sub/ > .git/info/sparse-checkout && |
90 | git read-tree -m -u HEAD && | |
91 | git ls-files -t > result && | |
7f71a6ae | 92 | test_cmp expected.swt-noinit result && |
d6b38f61 NTND |
93 | test ! -f init.t && |
94 | test -f sub/added | |
95 | ' | |
96 | ||
9037026d | 97 | test_expect_success 'match directories without trailing slash' ' |
7f71a6ae | 98 | echo sub >>.git/info/sparse-checkout && |
d6b38f61 | 99 | git read-tree -m -u HEAD && |
7f71a6ae | 100 | git ls-files -t >result && |
9037026d NTND |
101 | test_cmp expected.swt-noinit result && |
102 | test ! -f init.t && | |
103 | test -f sub/added | |
104 | ' | |
105 | ||
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 && | |
d6b38f61 NTND |
111 | test ! -f init.t && |
112 | test -f sub/added | |
113 | ' | |
114 | ||
d6b38f61 | 115 | test_expect_success 'checkout area changes' ' |
7f71a6ae JN |
116 | cat >expected.swt-nosub <<-\EOF && |
117 | H init.t | |
118 | S sub/added | |
ae3cdfe1 | 119 | S subsub/added |
7f71a6ae JN |
120 | EOF |
121 | ||
122 | echo init.t >.git/info/sparse-checkout && | |
d6b38f61 | 123 | git read-tree -m -u HEAD && |
7f71a6ae JN |
124 | git ls-files -t >result && |
125 | test_cmp expected.swt-nosub result && | |
d6b38f61 NTND |
126 | test -f init.t && |
127 | test ! -f sub/added | |
128 | ' | |
129 | ||
130 | test_expect_success 'read-tree updates worktree, absent case' ' | |
7f71a6ae | 131 | echo sub/added >.git/info/sparse-checkout && |
d6b38f61 NTND |
132 | git checkout -f top && |
133 | git read-tree -m -u HEAD^ && | |
134 | test ! -f init.t | |
135 | ' | |
136 | ||
137 | test_expect_success 'read-tree updates worktree, dirty case' ' | |
7f71a6ae | 138 | echo sub/added >.git/info/sparse-checkout && |
d6b38f61 | 139 | git checkout -f top && |
7f71a6ae | 140 | echo dirty >init.t && |
d6b38f61 NTND |
141 | git read-tree -m -u HEAD^ && |
142 | grep -q dirty init.t && | |
143 | rm init.t | |
144 | ' | |
145 | ||
146 | test_expect_success 'read-tree removes worktree, dirty case' ' | |
7f71a6ae | 147 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 | 148 | git checkout -f top && |
7f71a6ae | 149 | echo dirty >added && |
d6b38f61 NTND |
150 | git read-tree -m -u HEAD^ && |
151 | grep -q dirty added | |
152 | ' | |
153 | ||
154 | test_expect_success 'read-tree adds to worktree, absent case' ' | |
7f71a6ae | 155 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 NTND |
156 | git checkout -f removed && |
157 | git read-tree -u -m HEAD^ && | |
158 | test ! -f sub/added | |
159 | ' | |
160 | ||
74da98f9 | 161 | test_expect_success 'read-tree adds to worktree, dirty case' ' |
7f71a6ae | 162 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 NTND |
163 | git checkout -f removed && |
164 | mkdir sub && | |
7f71a6ae | 165 | echo dirty >sub/added && |
d6b38f61 NTND |
166 | git read-tree -u -m HEAD^ && |
167 | grep -q dirty sub/added | |
168 | ' | |
169 | ||
eec3fc03 NTND |
170 | test_expect_success 'index removal and worktree narrowing at the same time' ' |
171 | >empty && | |
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 | |
180 | ' | |
181 | ||
700e66d6 NTND |
182 | test_expect_success 'read-tree --reset removes outside worktree' ' |
183 | >empty && | |
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 | |
189 | ' | |
190 | ||
d6b38f61 | 191 | test_done |