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' '
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
'basic map' '
111 client_view "//depot/dir1/... //client/cli1/..." &&
112 files="cli1/file11 cli1/file12" &&
113 client_verify $files &&
114 test_when_finished cleanup_git &&
115 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
119 test_expect_success
'client view with no mappings' '
122 test_when_finished cleanup_git &&
123 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
127 test_expect_success
'single file map' '
128 client_view "//depot/dir1/file11 //client/file11" &&
130 client_verify $files &&
131 test_when_finished cleanup_git &&
132 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
136 test_expect_success
'later mapping takes precedence (entire repo)' '
137 client_view "//depot/dir1/... //client/cli1/..." \
138 "//depot/... //client/cli2/..." &&
139 files="cli2/dir1/file11 cli2/dir1/file12
140 cli2/dir2/file21 cli2/dir2/file22" &&
141 client_verify $files &&
142 test_when_finished cleanup_git &&
143 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
147 test_expect_success
'later mapping takes precedence (partial repo)' '
148 client_view "//depot/dir1/... //client/..." \
149 "//depot/dir2/... //client/..." &&
150 files="file21 file22" &&
151 client_verify $files &&
152 test_when_finished cleanup_git &&
153 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
157 # Reading the view backwards,
159 # dir1 cannot go to cli12 since it was filled by dir2
160 # dir1 also does not go to cli3, since the second rule
161 # noticed that it matched, but was already filled
162 test_expect_success
'depot path matching rejected client path' '
163 client_view "//depot/dir1/... //client/cli3/..." \
164 "//depot/dir1/... //client/cli12/..." \
165 "//depot/dir2/... //client/cli12/..." &&
166 files="cli12/file21 cli12/file22" &&
167 client_verify $files &&
168 test_when_finished cleanup_git &&
169 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
173 # since both have the same //client/..., the exclusion
174 # rule keeps everything out
175 test_expect_success
'exclusion wildcard, client rhs same (odd)' '
176 client_view "//depot/... //client/..." \
177 "-//depot/dir2/... //client/..." &&
179 test_when_finished cleanup_git &&
180 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
184 test_expect_success
'exclusion wildcard, client rhs different (normal)' '
185 client_view "//depot/... //client/..." \
186 "-//depot/dir2/... //client/dir2/..." &&
187 files="dir1/file11 dir1/file12" &&
188 client_verify $files &&
189 test_when_finished cleanup_git &&
190 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
194 test_expect_success
'exclusion single file' '
195 client_view "//depot/... //client/..." \
196 "-//depot/dir2/file22 //client/file22" &&
197 files="dir1/file11 dir1/file12 dir2/file21" &&
198 client_verify $files &&
199 test_when_finished cleanup_git &&
200 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
204 test_expect_success
'overlay wildcard' '
205 client_view "//depot/dir1/... //client/cli/..." \
206 "+//depot/dir2/... //client/cli/...\n" &&
207 files="cli/file11 cli/file12 cli/file21 cli/file22" &&
208 client_verify $files &&
209 test_when_finished cleanup_git &&
210 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
214 test_expect_success
'overlay single file' '
215 client_view "//depot/dir1/... //client/cli/..." \
216 "+//depot/dir2/file21 //client/cli/file21" &&
217 files="cli/file11 cli/file12 cli/file21" &&
218 client_verify $files &&
219 test_when_finished cleanup_git &&
220 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
224 test_expect_success
'exclusion with later inclusion' '
225 client_view "//depot/... //client/..." \
226 "-//depot/dir2/... //client/dir2/..." \
227 "//depot/dir2/... //client/dir2incl/..." &&
228 files="dir1/file11 dir1/file12 dir2incl/file21 dir2incl/file22" &&
229 client_verify $files &&
230 test_when_finished cleanup_git &&
231 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
235 test_expect_success
'quotes on rhs only' '
236 client_view "//depot/dir1/... \"//client/cdir 1/...\"" &&
237 client_verify "cdir 1/file11" "cdir 1/file12" &&
238 test_when_finished cleanup_git &&
239 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
240 git_verify "cdir 1/file11" "cdir 1/file12"
244 # Rename directories to test quoting in depot-side mappings
253 test_expect_success
'rename files to introduce spaces' '
254 client_view "//depot/... //client/..." &&
255 client_verify dir1/file11 dir1/file12 \
256 dir2/file21 dir2/file22 &&
260 p4 move dir1/... "dir 1"/... &&
262 p4 move dir2/... "dir 2"/... &&
263 p4 submit -d "rename with spaces"
265 client_verify "dir 1/file11" "dir 1/file12" \
266 "dir 2/file21" "dir 2/file22"
269 test_expect_success
'quotes on lhs only' '
270 client_view "\"//depot/dir 1/...\" //client/cdir1/..." &&
271 files="cdir1/file11 cdir1/file12" &&
272 client_verify $files &&
273 test_when_finished cleanup_git &&
274 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
278 test_expect_success
'quotes on both sides' '
279 client_view "\"//depot/dir 1/...\" \"//client/cdir 1/...\"" &&
280 client_verify "cdir 1/file11" "cdir 1/file12" &&
281 test_when_finished cleanup_git &&
282 "$GITP4" clone --use-client-spec --dest="$git" //depot &&
283 git_verify "cdir 1/file11" "cdir 1/file12"
286 test_expect_success
'kill p4d' '