From: Lars Schneider Date: Wed, 16 Sep 2015 12:37:04 +0000 (+0200) Subject: git-p4: improve path encoding verbose output X-Git-Tag: v2.7.0-rc0~124^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/00a9403?hp=a9e38359e356de7d6397395bdde8af61440262d0 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: Lars Schneider Signed-off-by: Junio C Hamano --- diff --git a/git-p4.py b/git-p4.py index b1ad86de7f..65feb22f58 100755 --- a/git-p4.py +++ b/git-p4.py @@ -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))