@@ -322,6 +322,89 @@ test_expect_success 'detect renames' '
322
322
p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
323
323
'
324
324
325
+ # Copy a file and confirm that copy is not detected in P4.
326
+ # Copy a file with detectCopies option enabled and confirm that copy is not
327
+ # detected in P4.
328
+ # Modify and copy a file with detectCopies option enabled and confirm that copy
329
+ # is detected in P4.
330
+ # Copy a file with detectCopies and detectCopiesHarder options enabled and
331
+ # confirm that copy is detected in P4.
332
+ # Modify and copy a file, configure a bigger threshold in detectCopies and
333
+ # confirm that copy is not detected in P4.
334
+ # Modify and copy a file, configure a smaller threshold in detectCopies and
335
+ # confirm that copy is detected in P4.
336
+ test_expect_success ' detect copies' '
337
+ "$GITP4" clone --dest="$git" //depot@all &&
338
+ test_when_finished cleanup_git &&
339
+ cd "$git" &&
340
+ git config git-p4.skipSubmitEditCheck true &&
341
+
342
+ cp file2 file8 &&
343
+ git add file8 &&
344
+ git commit -a -m "Copy file2 to file8" &&
345
+ git diff-tree -r -C HEAD &&
346
+ "$GITP4" submit &&
347
+ p4 filelog //depot/file8 &&
348
+ ! p4 filelog //depot/file8 | grep -q "branch from" &&
349
+
350
+ cp file2 file9 &&
351
+ git add file9 &&
352
+ git commit -a -m "Copy file2 to file9" &&
353
+ git diff-tree -r -C HEAD &&
354
+ git config git-p4.detectCopies true &&
355
+ "$GITP4" submit &&
356
+ p4 filelog //depot/file9 &&
357
+ ! p4 filelog //depot/file9 | grep -q "branch from" &&
358
+
359
+ echo "file2" >>file2 &&
360
+ cp file2 file10 &&
361
+ git add file2 file10 &&
362
+ git commit -a -m "Modify and copy file2 to file10" &&
363
+ git diff-tree -r -C HEAD &&
364
+ "$GITP4" submit &&
365
+ p4 filelog //depot/file10 &&
366
+ p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
367
+
368
+ cp file2 file11 &&
369
+ git add file11 &&
370
+ git commit -a -m "Copy file2 to file11" &&
371
+ git diff-tree -r -C --find-copies-harder HEAD &&
372
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
373
+ test "$src" = file10 &&
374
+ git config git-p4.detectCopiesHarder true &&
375
+ "$GITP4" submit &&
376
+ p4 filelog //depot/file11 &&
377
+ p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
378
+
379
+ cp file2 file12 &&
380
+ echo "some text" >>file12 &&
381
+ git add file12 &&
382
+ git commit -a -m "Copy file2 to file12 with changes" &&
383
+ git diff-tree -r -C --find-copies-harder HEAD &&
384
+ level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
385
+ test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
386
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
387
+ test "$src" = file10 &&
388
+ git config git-p4.detectCopies $((level + 2)) &&
389
+ "$GITP4" submit &&
390
+ p4 filelog //depot/file12 &&
391
+ ! p4 filelog //depot/file12 | grep -q "branch from" &&
392
+
393
+ cp file2 file13 &&
394
+ echo "different text" >>file13 &&
395
+ git add file13 &&
396
+ git commit -a -m "Copy file2 to file13 with changes" &&
397
+ git diff-tree -r -C --find-copies-harder HEAD &&
398
+ level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
399
+ test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
400
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
401
+ test "$src" = file10 &&
402
+ git config git-p4.detectCopies $((level - 2)) &&
403
+ "$GITP4" submit &&
404
+ p4 filelog //depot/file13 &&
405
+ p4 filelog //depot/file13 | grep -q "branch from //depot/file"
406
+ '
407
+
325
408
test_expect_success ' shutdown' '
326
409
pid=`pgrep -f p4d` &&
327
410
test -n "$pid" &&
0 commit comments