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
This commit is contained in:
Junio C Hamano
2015-10-07 13:38:19 -07:00
3 changed files with 75 additions and 0 deletions

View File

@ -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...