git-p4: add config git-p4.pathEncoding
[gitweb.git] / git-p4.py
index 073f87bbfdc1dc7ebc3fe610e78709667f597d82..b1ad86de7f2b735bcad05d32762e11bf460219fa 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -2213,6 +2213,17 @@ def streamOneP4File(self, file, contents):
             text = regexp.sub(r'$\1$', text)
             contents = [ text ]
 
+        if gitConfig("git-p4.pathEncoding"):
+            relPath = relPath.decode(gitConfig("git-p4.pathEncoding")).encode('utf8', 'replace')
+        elif self.verbose:
+            try:
+                relPath.decode('ascii')
+            except:
+                print (
+                    "Path with Non-ASCII characters detected and no path encoding defined. "
+                    "Please check the encoding: %s" % relPath
+                )
+
         self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
 
         # total length...