git-p4: fix filetype detection on files opened exclusively
authorBlair Holloway <blair_holloway@playstation.sony.com>
Sat, 4 Apr 2015 08:46:03 +0000 (09:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 4 Apr 2015 19:43:20 +0000 (12:43 -0700)
If a Perforce server is configured to automatically set +l
(exclusive lock) on add of certain file types, git p4 submit will
fail during getP4OpenedType, as the regex doesn't expect the
trailing '*exclusive*' from p4 opened:

//depot/file.png#1 - add default change (binary+l) *exclusive*

Signed-off-by: Blair Holloway <blair_holloway@playstation.sony.com>
Acked-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
t/t9816-git-p4-locked.sh
index 549022e97c83e4a2f1898dc005331e5bca3f0ded..2e1c4af1910d6c246aa7a73e76d0026f67580cc1 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -368,7 +368,7 @@ def getP4OpenedType(file):
     # Returns the perforce file type for the given file.
 
     result = p4_read_pipe(["opened", wildcard_encode(file)])
-    match = re.match(".*\((.+)\)\r?$", result)
+    match = re.match(".*\((.+)\)( \*exclusive\*)?\r?$", result)
     if match:
         return match.group(1)
     else:
index 464f10bd49fc584f2053aea60065869713f50470..d048bd33fa3c94402eb750b65553f72b955aa25f 100755 (executable)
@@ -35,7 +35,7 @@ test_expect_success 'edit with lock not taken' '
        )
 '
 
-test_expect_failure 'add with lock not taken' '
+test_expect_success 'add with lock not taken' '
        test_when_finished cleanup_git &&
        git p4 clone --dest="$git" //depot &&
        (
@@ -107,7 +107,7 @@ test_expect_failure 'chmod with lock taken' '
        )
 '
 
-test_expect_failure 'copy with lock taken' '
+test_expect_success 'copy with lock taken' '
        lock_in_another_client &&
        test_when_finished cleanup_git &&
        test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" &&