# [PATCH] git-p4: fix filetype detection on files opened exclusively

3 messages from 2015-03-31 to 2015-04-02. Participants: Holloway, Blair, Luke Diamand, Junio C Hamano.
Thread: https://gitlist.dev/t/38965

## Holloway, Blair, 2015-03-31 21:54

Subject: [PATCH] git-p4: fix filetype detection on files opened exclusively
Message-ID: <2D2A7688059E344DB86768405D63DEB42D3D75FC@USCULXMSG09.am.sony.com>
URL: https://gitlist.dev/e/2D2A7688059E344DB86768405D63DEB42D3D75FC%40USCULXMSG09.am.sony.com

```
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>
---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index ff132b2..d43482a 100755
--- 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:
-- 
1.8.3.msysgit.0

```

## Luke Diamand, 2015-04-02 19:54

Subject: Re: [PATCH] git-p4: fix filetype detection on files opened exclusively
Message-ID: <CAE5ih7_QpkX-U+XJ8gKSKKt1+Vu+FM4XBADTkys-4MDa129jyw@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih7_QpkX-U%2BXJ8gKSKKt1%2BVu%2BFM4XBADTkys-4MDa129jyw%40mail.gmail.com
In-Reply-To: <2D2A7688059E344DB86768405D63DEB42D3D75FC@USCULXMSG09.am.sony.com>

```
(+Pete for interest).

On 31 March 2015 at 22:54, Holloway, Blair
<Blair_Holloway@playstation.sony.com> wrote:
> 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:

Thanks - that actually fixes a part of the long-standing problem of
handling locked files which Pete identified about a year ago.

There's a test case for handling of locked files,
t9816-git-p4-locked.sh, which needs updating now as a bit more of it
passes. Junio, I'll submit a followup patch to update those tests once
I get back from vacation.

(Fixing t9816 is very slightly non-trivial because test #4 is subtly
broken and so incorrectly passes).

Ack,
Luke

```

## Junio C Hamano, 2015-04-02 21:17

Subject: Re: [PATCH] git-p4: fix filetype detection on files opened exclusively
Message-ID: <xmqqiodei624.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqiodei624.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAE5ih7_QpkX-U+XJ8gKSKKt1+Vu+FM4XBADTkys-4MDa129jyw@mail.gmail.com>

```
Luke Diamand <luke@diamand.org> writes:

> (+Pete for interest).
>
> On 31 March 2015 at 22:54, Holloway, Blair
> <Blair_Holloway@playstation.sony.com> wrote:
>> 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:
>
> Thanks - that actually fixes a part of the long-standing problem of
> handling locked files which Pete identified about a year ago.
>
> There's a test case for handling of locked files,
> t9816-git-p4-locked.sh, which needs updating now as a bit more of it
> passes. Junio, I'll submit a followup patch to update those tests once
> I get back from vacation.

Thanks.  Lest I forget, I'd prefer this patch resent from you in a
two (or more) patch series, with this one marked as 1/N with your
"Acked-by:", and your follow-up patches 2/N...N/N.  If it is not a
too much work for you, that is.

Thanks.

```
