git-p4: use replacement character for non UTF-8 characters in paths
authorLars Schneider <larsxschneider@gmail.com>
Mon, 21 Sep 2015 08:49:18 +0000 (10:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Sep 2015 20:24:11 +0000 (13:24 -0700)
If non UTF-8 characters are detected in paths then replace them with
a placeholder 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>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
index 65feb22f58f89e425302e7a8e3428c0af8c9619a..603045050c95ca1d5fb4843203f2a811e5c3e95a 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -2219,7 +2219,7 @@ def streamOneP4File(self, file, contents):
             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)