# [PATCH v3] git-p4: use replacement character for non UTF-8 characters in paths

4 messages from 2015-09-21 to 2015-09-21. Participants: larsxschneider@gmail.com, Luke Diamand, Junio C Hamano.
Thread: https://gitlist.dev/t/40392

## larsxschneider@gmail.com, 2015-09-21 08:49

Subject: [PATCH v3] git-p4: use replacement character for non UTF-8 characters in paths
Message-ID: <1442825358-90294-1-git-send-email-larsxschneider@gmail.com>
URL: https://gitlist.dev/e/1442825358-90294-1-git-send-email-larsxschneider%40gmail.com

```
From: Lars Schneider <larsxschneider@gmail.com>

I broke a test in "[PATCH v2] git-p4: improve path encoding verbose output" on the next branch.
This patch on top of next (3dd15c0) fixes the issue.

Thanks to Luke for finding the issue!

Cheers,
Lars

Lars Schneider (1):
  git-p4: use replacement character for non UTF-8 characters in paths

 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.5.1

```

## larsxschneider@gmail.com, 2015-09-21 08:49

Subject: [PATCH v3] git-p4: use replacement character for non UTF-8 characters in paths
Message-ID: <1442825358-90294-2-git-send-email-larsxschneider@gmail.com>
URL: https://gitlist.dev/e/1442825358-90294-2-git-send-email-larsxschneider%40gmail.com
In-Reply-To: <1442825358-90294-1-git-send-email-larsxschneider@gmail.com>

```
From: Lars Schneider <larsxschneider@gmail.com>

If non UTF-8 characters are detected in paths then replace them with �
instead of throwing a UnicodeDecodeError exception. This restores the
original (implicit) implementation that was broken in 00a9403.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index e7510a9..215f556 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2226,7 +2226,7 @@ class P4Sync(Command, P4UserMap):
             encoding = 'utf8'
             if gitConfig('git-p4.pathEncoding'):
                 encoding = gitConfig('git-p4.pathEncoding')
-            relPath = relPath.decode(encoding).encode('utf8', 'replace')
+            relPath = relPath.decode(encoding, 'replace').encode('utf8', 'replace')
             if self.verbose:
                 print 'Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, relPath)
 
-- 
2.5.1

```

## Luke Diamand, 2015-09-21 19:34

Subject: Re: [PATCH v3] git-p4: use replacement character for non UTF-8 characters in paths
Message-ID: <56005BDD.6050508@diamand.org>
URL: https://gitlist.dev/e/56005BDD.6050508%40diamand.org
In-Reply-To: <1442825358-90294-1-git-send-email-larsxschneider@gmail.com>

```
On 21/09/15 09:49, larsxschneider@gmail.com wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
>
> I broke a test in "[PATCH v2] git-p4: improve path encoding verbose output" on the next branch.
> This patch on top of next (3dd15c0) fixes the issue.
>
> Thanks to Luke for finding the issue!

Looks good to me, apart from using a UTF-8 char in the comment itself, 
which seems a bit unnecessary. Imagine what will happen to someone using 
git-p4 to mirror git-p4 itself into p4!


>
> Cheers,
> Lars
>
> Lars Schneider (1):
>    git-p4: use replacement character for non UTF-8 characters in paths
>
>   git-p4.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> --
> 2.5.1
>

```

## Junio C Hamano, 2015-09-21 20:23

Subject: Re: [PATCH v3] git-p4: use replacement character for non UTF-8 characters in paths
Message-ID: <xmqqwpvj8qtq.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqwpvj8qtq.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <56005BDD.6050508@diamand.org>

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

> On 21/09/15 09:49, larsxschneider@gmail.com wrote:
>> From: Lars Schneider <larsxschneider@gmail.com>
>>
>> I broke a test in "[PATCH v2] git-p4: improve path encoding verbose
>> output" on the next branch.
>> This patch on top of next (3dd15c0) fixes the issue.
>>
>> Thanks to Luke for finding the issue!
>
> Looks good to me, apart from using a UTF-8 char in the comment itself,
> which seems a bit unnecessary. Imagine what will happen to someone
> using git-p4 to mirror git-p4 itself into p4!

;-)  Thanks.

>
>
>>
>> Cheers,
>> Lars
>>
>> Lars Schneider (1):
>>    git-p4: use replacement character for non UTF-8 characters in paths
>>
>>   git-p4.py | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> --
>> 2.5.1
>>

```
