summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-07 20:38:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-07 20:38:19 (GMT)
commit98f9556a442647db60dad9c7a754832c16af9e73 (patch)
treeb427b3625d48b1ffa3cd1bedb7d399c9db5043eb /git-p4.py
parenta23d263b69d353e6945281cd1a19fa6f1d0aaeee (diff)
parent4cb870d8042bef3fdd953c633463eda24ce78f3d (diff)
downloadgit-98f9556a442647db60dad9c7a754832c16af9e73.zip
git-98f9556a442647db60dad9c7a754832c16af9e73.tar.gz
git-98f9556a442647db60dad9c7a754832c16af9e73.tar.bz2
Merge branch 'ls/p4-path-encoding'
"git p4" learned to reencode the pathname it uses to communicate with the p4 depot with a new option. * ls/p4-path-encoding: git-p4: use replacement character for non UTF-8 characters in paths git-p4: improve path encoding verbose output git-p4: add config git-p4.pathEncoding
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/git-p4.py b/git-p4.py
index 2677c89..215f556 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2220,6 +2220,16 @@ class P4Sync(Command, P4UserMap):
text = regexp.sub(r'$\1$', text)
contents = [ text ]
+ try:
+ relPath.decode('ascii')
+ except:
+ encoding = 'utf8'
+ if gitConfig('git-p4.pathEncoding'):
+ encoding = gitConfig('git-p4.pathEncoding')
+ 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)
+
self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
# total length...