]>
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 | |
20 | EOF | |
21 | cat >expected.swt <<-\EOF && | |
22 | H init.t | |
23 | H sub/added | |
24 | EOF | |
25 | ||
d6b38f61 | 26 | test_commit init && |
7f71a6ae | 27 | echo modified >>init.t && |
d6b38f61 NTND |
28 | mkdir sub && |
29 | touch sub/added && | |
30 | git add init.t sub/added && | |
31 | git commit -m "modified and added" && | |
32 | git tag top && | |
33 | git rm sub/added && | |
34 | git commit -m removed && | |
35 | git tag removed && | |
36 | git checkout top && | |
7f71a6ae | 37 | git ls-files --stage >result && |
d6b38f61 NTND |
38 | test_cmp expected result |
39 | ' | |
40 | ||
d6b38f61 NTND |
41 | test_expect_success 'read-tree without .git/info/sparse-checkout' ' |
42 | git read-tree -m -u HEAD && | |
7f71a6ae | 43 | git ls-files --stage >result && |
d6b38f61 | 44 | test_cmp expected result && |
7f71a6ae | 45 | git ls-files -t >result && |
d6b38f61 NTND |
46 | test_cmp expected.swt result |
47 | ' | |
48 | ||
49 | test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' ' | |
7f71a6ae | 50 | echo >.git/info/sparse-checkout |
d6b38f61 | 51 | git read-tree -m -u HEAD && |
7f71a6ae | 52 | git ls-files -t >result && |
d6b38f61 NTND |
53 | test_cmp expected.swt result && |
54 | test -f init.t && | |
55 | test -f sub/added | |
56 | ' | |
57 | ||
58 | test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' ' | |
59 | git config core.sparsecheckout true && | |
7f71a6ae | 60 | echo >.git/info/sparse-checkout && |
d6b38f61 | 61 | git read-tree --no-sparse-checkout -m -u HEAD && |
7f71a6ae | 62 | git ls-files -t >result && |
d6b38f61 NTND |
63 | test_cmp expected.swt result && |
64 | test -f init.t && | |
65 | test -f sub/added | |
66 | ' | |
67 | ||
d6b38f61 NTND |
68 | test_expect_success 'read-tree with empty .git/info/sparse-checkout' ' |
69 | git config core.sparsecheckout true && | |
7f71a6ae | 70 | echo >.git/info/sparse-checkout && |
9e1afb16 | 71 | test_must_fail git read-tree -m -u HEAD && |
7f71a6ae | 72 | git ls-files --stage >result && |
d6b38f61 | 73 | test_cmp expected result && |
7f71a6ae | 74 | git ls-files -t >result && |
d6b38f61 | 75 | test_cmp expected.swt result && |
9e1afb16 NTND |
76 | test -f init.t && |
77 | test -f sub/added | |
d6b38f61 NTND |
78 | ' |
79 | ||
d6b38f61 | 80 | test_expect_success 'match directories with trailing slash' ' |
7f71a6ae JN |
81 | cat >expected.swt-noinit <<-\EOF && |
82 | S init.t | |
83 | H sub/added | |
84 | EOF | |
85 | ||
d6b38f61 NTND |
86 | echo sub/ > .git/info/sparse-checkout && |
87 | git read-tree -m -u HEAD && | |
88 | git ls-files -t > result && | |
7f71a6ae | 89 | test_cmp expected.swt-noinit result && |
d6b38f61 NTND |
90 | test ! -f init.t && |
91 | test -f sub/added | |
92 | ' | |
93 | ||
d6b38f61 | 94 | test_expect_failure 'match directories without trailing slash' ' |
7f71a6ae JN |
95 | echo init.t >.git/info/sparse-checkout && |
96 | echo sub >>.git/info/sparse-checkout && | |
d6b38f61 | 97 | git read-tree -m -u HEAD && |
7f71a6ae | 98 | git ls-files -t >result && |
d6b38f61 NTND |
99 | test_cmp expected.swt result && |
100 | test ! -f init.t && | |
101 | test -f sub/added | |
102 | ' | |
103 | ||
d6b38f61 | 104 | test_expect_success 'checkout area changes' ' |
7f71a6ae JN |
105 | cat >expected.swt-nosub <<-\EOF && |
106 | H init.t | |
107 | S sub/added | |
108 | EOF | |
109 | ||
110 | echo init.t >.git/info/sparse-checkout && | |
d6b38f61 | 111 | git read-tree -m -u HEAD && |
7f71a6ae JN |
112 | git ls-files -t >result && |
113 | test_cmp expected.swt-nosub result && | |
d6b38f61 NTND |
114 | test -f init.t && |
115 | test ! -f sub/added | |
116 | ' | |
117 | ||
118 | test_expect_success 'read-tree updates worktree, absent case' ' | |
7f71a6ae | 119 | echo sub/added >.git/info/sparse-checkout && |
d6b38f61 NTND |
120 | git checkout -f top && |
121 | git read-tree -m -u HEAD^ && | |
122 | test ! -f init.t | |
123 | ' | |
124 | ||
125 | test_expect_success 'read-tree updates worktree, dirty case' ' | |
7f71a6ae | 126 | echo sub/added >.git/info/sparse-checkout && |
d6b38f61 | 127 | git checkout -f top && |
7f71a6ae | 128 | echo dirty >init.t && |
d6b38f61 NTND |
129 | git read-tree -m -u HEAD^ && |
130 | grep -q dirty init.t && | |
131 | rm init.t | |
132 | ' | |
133 | ||
134 | test_expect_success 'read-tree removes worktree, dirty case' ' | |
7f71a6ae | 135 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 | 136 | git checkout -f top && |
7f71a6ae | 137 | echo dirty >added && |
d6b38f61 NTND |
138 | git read-tree -m -u HEAD^ && |
139 | grep -q dirty added | |
140 | ' | |
141 | ||
142 | test_expect_success 'read-tree adds to worktree, absent case' ' | |
7f71a6ae | 143 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 NTND |
144 | git checkout -f removed && |
145 | git read-tree -u -m HEAD^ && | |
146 | test ! -f sub/added | |
147 | ' | |
148 | ||
74da98f9 | 149 | test_expect_success 'read-tree adds to worktree, dirty case' ' |
7f71a6ae | 150 | echo init.t >.git/info/sparse-checkout && |
d6b38f61 NTND |
151 | git checkout -f removed && |
152 | mkdir sub && | |
7f71a6ae | 153 | echo dirty >sub/added && |
d6b38f61 NTND |
154 | git read-tree -u -m HEAD^ && |
155 | grep -q dirty sub/added | |
156 | ' | |
157 | ||
eec3fc03 NTND |
158 | test_expect_success 'index removal and worktree narrowing at the same time' ' |
159 | >empty && | |
160 | echo init.t >.git/info/sparse-checkout && | |
161 | echo sub/added >>.git/info/sparse-checkout && | |
162 | git checkout -f top && | |
163 | echo init.t >.git/info/sparse-checkout && | |
164 | git checkout removed && | |
165 | git ls-files sub/added >result && | |
166 | test ! -f sub/added && | |
167 | test_cmp empty result | |
168 | ' | |
169 | ||
700e66d6 NTND |
170 | test_expect_success 'read-tree --reset removes outside worktree' ' |
171 | >empty && | |
172 | echo init.t >.git/info/sparse-checkout && | |
173 | git checkout -f top && | |
174 | git reset --hard removed && | |
175 | git ls-files sub/added >result && | |
176 | test_cmp empty result | |
177 | ' | |
178 | ||
d6b38f61 | 179 | test_done |