Commit 00a9403a authored by Lars Schneider's avatar Lars Schneider Committed by Junio C Hamano

git-p4: improve path encoding verbose output

If a path with non-ASCII characters is detected then print the
encoding and the encoded string in verbose mode.
Signed-off-by: default avatarLars Schneider <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent a9e38359
......@@ -2213,16 +2213,15 @@ 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
)
try:
relPath.decode('ascii')
except:
encoding = 'utf8'
if gitConfig('git-p4.pathEncoding'):
encoding = gitConfig('git-p4.pathEncoding')
relPath = relPath.decode(encoding).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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment