@@ -71,20 +71,24 @@ git_verify() {
71
71
# - dir2
72
72
# - file21
73
73
# - file22
74
+ init_depot () {
75
+ for d in 1 2 ; do
76
+ mkdir -p dir$d &&
77
+ for f in 1 2 ; do
78
+ echo dir$d /file$d$f > dir$d /file$d$f &&
79
+ p4 add dir$d /file$d$f &&
80
+ p4 submit -d " dir$d /file$d$f "
81
+ done
82
+ done &&
83
+ find . -type f ! -name files > files &&
84
+ check_files_exist dir1/file11 dir1/file12 \
85
+ dir2/file21 dir2/file22
86
+ }
87
+
74
88
test_expect_success ' init depot' '
75
89
(
76
90
cd "$cli" &&
77
- for d in 1 2 ; do
78
- mkdir -p dir$d &&
79
- for f in 1 2 ; do
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"
83
- done
84
- done &&
85
- find . -type f ! -name files >files &&
86
- check_files_exist dir1/file11 dir1/file12 \
87
- dir2/file21 dir2/file22
91
+ init_depot
88
92
)
89
93
'
90
94
@@ -257,6 +261,122 @@ test_expect_success 'clone --use-client-spec sets useClientSpec' '
257
261
)
258
262
'
259
263
264
+ # clone just a subdir of the client spec
265
+ test_expect_success ' subdir clone' '
266
+ client_view "//depot/... //client/..." &&
267
+ files="dir1/file11 dir1/file12 dir2/file21 dir2/file22" &&
268
+ client_verify $files &&
269
+ test_when_finished cleanup_git &&
270
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
271
+ git_verify dir1/file11 dir1/file12
272
+ '
273
+
274
+ #
275
+ # submit back, see what happens: five cases
276
+ #
277
+ test_expect_success ' subdir clone, submit modify' '
278
+ client_view "//depot/... //client/..." &&
279
+ test_when_finished cleanup_git &&
280
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
281
+ (
282
+ cd "$git" &&
283
+ git config git-p4.skipSubmitEdit true &&
284
+ echo line >>dir1/file12 &&
285
+ git add dir1/file12 &&
286
+ git commit -m dir1/file12 &&
287
+ "$GITP4" submit
288
+ ) &&
289
+ (
290
+ cd "$cli" &&
291
+ test_path_is_file dir1/file12 &&
292
+ test_line_count = 2 dir1/file12
293
+ )
294
+ '
295
+
296
+ test_expect_success ' subdir clone, submit add' '
297
+ client_view "//depot/... //client/..." &&
298
+ test_when_finished cleanup_git &&
299
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
300
+ (
301
+ cd "$git" &&
302
+ git config git-p4.skipSubmitEdit true &&
303
+ echo file13 >dir1/file13 &&
304
+ git add dir1/file13 &&
305
+ git commit -m dir1/file13 &&
306
+ "$GITP4" submit
307
+ ) &&
308
+ (
309
+ cd "$cli" &&
310
+ test_path_is_file dir1/file13
311
+ )
312
+ '
313
+
314
+ test_expect_success ' subdir clone, submit delete' '
315
+ client_view "//depot/... //client/..." &&
316
+ test_when_finished cleanup_git &&
317
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
318
+ (
319
+ cd "$git" &&
320
+ git config git-p4.skipSubmitEdit true &&
321
+ git rm dir1/file12 &&
322
+ git commit -m "delete dir1/file12" &&
323
+ "$GITP4" submit
324
+ ) &&
325
+ (
326
+ cd "$cli" &&
327
+ test_path_is_missing dir1/file12
328
+ )
329
+ '
330
+
331
+ test_expect_success ' subdir clone, submit copy' '
332
+ client_view "//depot/... //client/..." &&
333
+ test_when_finished cleanup_git &&
334
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
335
+ (
336
+ cd "$git" &&
337
+ git config git-p4.skipSubmitEdit true &&
338
+ git config git-p4.detectCopies true &&
339
+ cp dir1/file11 dir1/file11a &&
340
+ git add dir1/file11a &&
341
+ git commit -m "copy to dir1/file11a" &&
342
+ "$GITP4" submit
343
+ ) &&
344
+ (
345
+ cd "$cli" &&
346
+ test_path_is_file dir1/file11a
347
+ )
348
+ '
349
+
350
+ test_expect_success ' subdir clone, submit rename' '
351
+ client_view "//depot/... //client/..." &&
352
+ test_when_finished cleanup_git &&
353
+ "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 &&
354
+ (
355
+ cd "$git" &&
356
+ git config git-p4.skipSubmitEdit true &&
357
+ git config git-p4.detectRenames true &&
358
+ git mv dir1/file13 dir1/file13a &&
359
+ git commit -m "rename dir1/file13 to dir1/file13a" &&
360
+ "$GITP4" submit
361
+ ) &&
362
+ (
363
+ cd "$cli" &&
364
+ test_path_is_missing dir1/file13 &&
365
+ test_path_is_file dir1/file13a
366
+ )
367
+ '
368
+
369
+ test_expect_success ' reinit depot' '
370
+ (
371
+ cd "$cli" &&
372
+ p4 sync -f &&
373
+ rm files &&
374
+ p4 delete */* &&
375
+ p4 submit -d "delete all files" &&
376
+ init_depot
377
+ )
378
+ '
379
+
260
380
#
261
381
# Rename directories to test quoting in depot-side mappings
262
382
# //depot
0 commit comments