use QSORT, part 2
[git/git-svn.git] / t / t9816-git-p4-locked.sh
blobd048bd33fa3c94402eb750b65553f72b955aa25f
1 #!/bin/sh
3 test_description='git p4 locked file behavior'
5 . ./lib-git-p4.sh
7 test_expect_success 'start p4d' '
8 start_p4d
11 # See
12 # http://www.perforce.com/perforce/doc.current/manuals/p4sag/03_superuser.html#1088563
13 # for suggestions on how to configure "sitewide pessimistic locking"
14 # where only one person can have a file open for edit at a time.
15 test_expect_success 'init depot' '
17 cd "$cli" &&
18 echo "TypeMap: +l //depot/..." | p4 typemap -i &&
19 echo file1 >file1 &&
20 p4 add file1 &&
21 p4 submit -d "add file1"
25 test_expect_success 'edit with lock not taken' '
26 test_when_finished cleanup_git &&
27 git p4 clone --dest="$git" //depot &&
29 cd "$git" &&
30 echo line2 >>file1 &&
31 git add file1 &&
32 git commit -m "line2 in file1" &&
33 git config git-p4.skipSubmitEdit true &&
34 git p4 submit
38 test_expect_success 'add with lock not taken' '
39 test_when_finished cleanup_git &&
40 git p4 clone --dest="$git" //depot &&
42 cd "$git" &&
43 echo line1 >>add-lock-not-taken &&
44 git add add-lock-not-taken &&
45 git commit -m "add add-lock-not-taken" &&
46 git config git-p4.skipSubmitEdit true &&
47 git p4 submit --verbose
51 lock_in_another_client() {
52 # build a different client
53 cli2="$TRASH_DIRECTORY/cli2" &&
54 mkdir -p "$cli2" &&
55 test_when_finished "p4 client -f -d client2 && rm -rf \"$cli2\"" &&
57 cd "$cli2" &&
58 P4CLIENT=client2 &&
59 cli="$cli2" &&
60 client_view "//depot/... //client2/..." &&
61 p4 sync &&
62 p4 open file1
66 test_expect_failure 'edit with lock taken' '
67 lock_in_another_client &&
68 test_when_finished cleanup_git &&
69 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
70 git p4 clone --dest="$git" //depot &&
72 cd "$git" &&
73 echo line3 >>file1 &&
74 git add file1 &&
75 git commit -m "line3 in file1" &&
76 git config git-p4.skipSubmitEdit true &&
77 git p4 submit --verbose
81 test_expect_failure 'delete with lock taken' '
82 lock_in_another_client &&
83 test_when_finished cleanup_git &&
84 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
85 git p4 clone --dest="$git" //depot &&
87 cd "$git" &&
88 git rm file1 &&
89 git commit -m "delete file1" &&
90 git config git-p4.skipSubmitEdit true &&
91 git p4 submit --verbose
95 test_expect_failure 'chmod with lock taken' '
96 lock_in_another_client &&
97 test_when_finished cleanup_git &&
98 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
99 git p4 clone --dest="$git" //depot &&
101 cd "$git" &&
102 chmod +x file1 &&
103 git add file1 &&
104 git commit -m "chmod +x file1" &&
105 git config git-p4.skipSubmitEdit true &&
106 git p4 submit --verbose
110 test_expect_success 'copy with lock taken' '
111 lock_in_another_client &&
112 test_when_finished cleanup_git &&
113 test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" &&
114 git p4 clone --dest="$git" //depot &&
116 cd "$git" &&
117 cp file1 file2 &&
118 git add file2 &&
119 git commit -m "cp file1 to file2" &&
120 git config git-p4.skipSubmitEdit true &&
121 git config git-p4.detectCopies true &&
122 git p4 submit --verbose
126 test_expect_failure 'move with lock taken' '
127 lock_in_another_client &&
128 test_when_finished cleanup_git &&
129 test_when_finished "cd \"$cli\" && p4 sync file1 && rm -f file2" &&
130 git p4 clone --dest="$git" //depot &&
132 cd "$git" &&
133 git mv file1 file3 &&
134 git commit -m "mv file1 to file3" &&
135 git config git-p4.skipSubmitEdit true &&
136 git config git-p4.detectRenames true &&
137 git p4 submit --verbose
141 test_expect_success 'kill p4d' '
142 kill_p4d
145 test_done