3 test_description='git-p4 client view'
7 test_expect_success 'start p4d' '
12 # Construct a client with this list of View lines
29 # Verify these files exist, exactly. Caller creates
30 # a list of files in file "files".
36 test_path_is_file "$arg" &&
40 test_line_count = $num files
44 # Sync up the p4 client, make sure the given files (and only
51 find . -type f ! -name files >files &&
52 check_files_exist "$@"
57 # Make sure the named files, exactly, exist.
62 git ls-files >files &&
63 check_files_exist "$@"
74 test_expect_success 'init depot' '
80 echo dir$d/file$d$f >dir$d/file$d$f &&
81 p4 add dir$d/file$d$f &&
82 p4 submit -d "dir$d/file$d$f"
85 find . -type f ! -name files >files &&
86 check_files_exist dir1/file11 dir1/file12 \
87 dir2/file21 dir2/file22
92 test_expect_success 'unsupported view wildcard %%n' '
93 client_view "//depot/%%%%1/sub/... //client/sub/%%%%1/..." &&
94 test_when_finished cleanup_git &&
95 test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot
98 test_expect_success 'unsupported view wildcard *' '
99 client_view "//depot/*/bar/... //client/*/bar/..." &&
100 test_when_finished cleanup_git &&
101 test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot
104 test_expect_success 'wildcard ... only supported at end of spec 1' '
105 client_view "//depot/.../file11 //client/.../file11" &&
106 test_when_finished cleanup_git &&
107 test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot
110 test_expect_success 'wildcard ... only supported at end of spec 2' '
111 client_view "//depot/.../a/... //client/.../a/..." &&
112 test_when_finished cleanup_git &&
113 test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot
116 test_expect_success 'basic map' '
117 client_view "//depot/dir1/... //client/cli1/..." &&
118 files="cli1/file11 cli1/file12" &&
119 client_verify $files &&
120 test_when_finished cleanup_git &&
121 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
125 test_expect_success 'client view with no mappings' '
128 test_when_finished cleanup_git &&
129 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
133 test_expect_success 'single file map' '
134 client_view "//depot/dir1/file11 //client/file11" &&
136 client_verify $files &&
137 test_when_finished cleanup_git &&
138 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
142 test_expect_success 'later mapping takes precedence (entire repo)' '
143 client_view "//depot/dir1/... //client/cli1/..." \
144 "//depot/... //client/cli2/..." &&
145 files="cli2/dir1/file11 cli2/dir1/file12
146 cli2/dir2/file21 cli2/dir2/file22" &&
147 client_verify $files &&
148 test_when_finished cleanup_git &&
149 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
153 test_expect_success 'later mapping takes precedence (partial repo)' '
154 client_view "//depot/dir1/... //client/..." \
155 "//depot/dir2/... //client/..." &&
156 files="file21 file22" &&
157 client_verify $files &&
158 test_when_finished cleanup_git &&
159 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
163 # Reading the view backwards,
165 # dir1 cannot go to cli12 since it was filled by dir2
166 # dir1 also does not go to cli3, since the second rule
167 # noticed that it matched, but was already filled
168 test_expect_success 'depot path matching rejected client path' '
169 client_view "//depot/dir1/... //client/cli3/..." \
170 "//depot/dir1/... //client/cli12/..." \
171 "//depot/dir2/... //client/cli12/..." &&
172 files="cli12/file21 cli12/file22" &&
173 client_verify $files &&
174 test_when_finished cleanup_git &&
175 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
179 # since both have the same //client/..., the exclusion
180 # rule keeps everything out
181 test_expect_success 'exclusion wildcard, client rhs same (odd)' '
182 client_view "//depot/... //client/..." \
183 "-//depot/dir2/... //client/..." &&
185 test_when_finished cleanup_git &&
186 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
190 test_expect_success 'exclusion wildcard, client rhs different (normal)' '
191 client_view "//depot/... //client/..." \
192 "-//depot/dir2/... //client/dir2/..." &&
193 files="dir1/file11 dir1/file12" &&
194 client_verify $files &&
195 test_when_finished cleanup_git &&
196 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
200 test_expect_success 'exclusion single file' '
201 client_view "//depot/... //client/..." \
202 "-//depot/dir2/file22 //client/file22" &&
203 files="dir1/file11 dir1/file12 dir2/file21" &&
204 client_verify $files &&
205 test_when_finished cleanup_git &&
206 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
210 test_expect_success 'overlay wildcard' '
211 client_view "//depot/dir1/... //client/cli/..." \
212 "+//depot/dir2/... //client/cli/...\n" &&
213 files="cli/file11 cli/file12 cli/file21 cli/file22" &&
214 client_verify $files &&
215 test_when_finished cleanup_git &&
216 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
220 test_expect_success 'overlay single file' '
221 client_view "//depot/dir1/... //client/cli/..." \
222 "+//depot/dir2/file21 //client/cli/file21" &&
223 files="cli/file11 cli/file12 cli/file21" &&
224 client_verify $files &&
225 test_when_finished cleanup_git &&
226 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
230 test_expect_success 'exclusion with later inclusion' '
231 client_view "//depot/... //client/..." \
232 "-//depot/dir2/... //client/dir2/..." \
233 "//depot/dir2/... //client/dir2incl/..." &&
234 files="dir1/file11 dir1/file12 dir2incl/file21 dir2incl/file22" &&
235 client_verify $files &&
236 test_when_finished cleanup_git &&
237 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
241 test_expect_success 'quotes on rhs only' '
242 client_view "//depot/dir1/... \"//client/cdir 1/...\"" &&
243 client_verify "cdir 1/file11" "cdir 1/file12" &&
244 test_when_finished cleanup_git &&
245 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
246 git_verify "cdir 1/file11" "cdir 1/file12"
250 # Rename directories to test quoting in depot-side mappings
259 test_expect_success 'rename files to introduce spaces' '
260 client_view "//depot/... //client/..." &&
261 client_verify dir1/file11 dir1/file12 \
262 dir2/file21 dir2/file22 &&
266 p4 move dir1/... "dir 1"/... &&
268 p4 move dir2/... "dir 2"/... &&
269 p4 submit -d "rename with spaces"
271 client_verify "dir 1/file11" "dir 1/file12" \
272 "dir 2/file21" "dir 2/file22"
275 test_expect_success 'quotes on lhs only' '
276 client_view "\"//depot/dir 1/...\" //client/cdir1/..." &&
277 files="cdir1/file11 cdir1/file12" &&
278 client_verify $files &&
279 test_when_finished cleanup_git &&
280 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
284 test_expect_success 'quotes on both sides' '
285 client_view "\"//depot/dir 1/...\" \"//client/cdir 1/...\"" &&
286 client_verify "cdir 1/file11" "cdir 1/file12" &&
287 test_when_finished cleanup_git &&
288 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
289 git_verify "cdir 1/file11" "cdir 1/file12"
292 test_expect_success 'kill p4d' '