3 test_description
='git p4 locked file behavior'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'start p4d' '
13 # https://web.archive.org/web/20150602090517/http://www.perforce.com/perforce/doc.current/manuals/p4sag/chapter.superuser.html#superuser.basic.typemap_locking
14 # for suggestions on how to configure "sitewide pessimistic locking"
15 # where only one person can have a file open for edit at a time.
16 test_expect_success
'init depot' '
19 echo "TypeMap: +l //depot/..." | p4 typemap -i &&
22 p4 submit -d "add file1"
26 test_expect_success
'edit with lock not taken' '
27 test_when_finished cleanup_git &&
28 git p4 clone --dest="$git" //depot &&
33 git commit -m "line2 in file1" &&
34 git config git-p4.skipSubmitEdit true &&
39 test_expect_success
'add with lock not taken' '
40 test_when_finished cleanup_git &&
41 git p4 clone --dest="$git" //depot &&
44 echo line1 >>add-lock-not-taken &&
45 git add add-lock-not-taken &&
46 git commit -m "add add-lock-not-taken" &&
47 git config git-p4.skipSubmitEdit true &&
48 git p4 submit --verbose
52 lock_in_another_client
() {
53 # build a different client
54 cli2
="$TRASH_DIRECTORY/cli2" &&
56 test_when_finished
"p4 client -f -d client2 && rm -rf \"$cli2\"" &&
61 client_view
"//depot/... //client2/..." &&
67 test_expect_failure
'edit with lock taken' '
68 lock_in_another_client &&
69 test_when_finished cleanup_git &&
70 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
71 git p4 clone --dest="$git" //depot &&
76 git commit -m "line3 in file1" &&
77 git config git-p4.skipSubmitEdit true &&
78 git p4 submit --verbose
82 test_expect_failure
'delete with lock taken' '
83 lock_in_another_client &&
84 test_when_finished cleanup_git &&
85 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
86 git p4 clone --dest="$git" //depot &&
90 git commit -m "delete file1" &&
91 git config git-p4.skipSubmitEdit true &&
92 git p4 submit --verbose
96 test_expect_failure
'chmod with lock taken' '
97 lock_in_another_client &&
98 test_when_finished cleanup_git &&
99 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
100 git p4 clone --dest="$git" //depot &&
105 git commit -m "chmod +x file1" &&
106 git config git-p4.skipSubmitEdit true &&
107 git p4 submit --verbose
111 test_expect_success
'copy with lock taken' '
112 lock_in_another_client &&
113 test_when_finished cleanup_git &&
114 test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" &&
115 git p4 clone --dest="$git" //depot &&
120 git commit -m "cp file1 to file2" &&
121 git config git-p4.skipSubmitEdit true &&
122 git config git-p4.detectCopies true &&
123 git p4 submit --verbose
127 test_expect_failure
'move with lock taken' '
128 lock_in_another_client &&
129 test_when_finished cleanup_git &&
130 test_when_finished "cd \"$cli\" && p4 sync file1 && rm -f file2" &&
131 git p4 clone --dest="$git" //depot &&
134 git mv file1 file3 &&
135 git commit -m "mv file1 to file3" &&
136 git config git-p4.skipSubmitEdit true &&
137 git config git-p4.detectRenames true &&
138 git p4 submit --verbose