aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcc-changelog/git_commit.py
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-01-06 08:11:57 +0100
committerMartin Liska <mliska@suse.cz>2021-01-06 08:26:10 +0100
commit57706dd7e001d8302b596521217827855324e748 (patch)
treefeeaa5162dd2fd4f0dfa4452d9694414857a39db /contrib/gcc-changelog/git_commit.py
parentac3966e315ada63eb379d560a012fa77c3909155 (diff)
downloadgcc-57706dd7e001d8302b596521217827855324e748.zip
gcc-57706dd7e001d8302b596521217827855324e748.tar.gz
gcc-57706dd7e001d8302b596521217827855324e748.tar.bz2
gcc-changelog: workaround for utf8 filenames
contrib/ChangeLog: * gcc-changelog/git_commit.py: Add decode_path function. * gcc-changelog/git_email.py: Use it in order to solve utf8 encoding filename issues. * gcc-changelog/git_repository.py: Likewise. * gcc-changelog/test_email.py: Test it.
Diffstat (limited to 'contrib/gcc-changelog/git_commit.py')
-rwxr-xr-xcontrib/gcc-changelog/git_commit.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index d2e5dbe..ee19733 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -174,6 +174,24 @@ REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ',
DATE_FORMAT = '%Y-%m-%d'
+def decode_path(path):
+ # When core.quotepath is true (default value), utf8 chars are encoded like:
+ # "b/ko\304\215ka.txt"
+ #
+ # The upstream bug is fixed:
+ # https://github.com/gitpython-developers/GitPython/issues/1099
+ #
+ # but we still need a workaround for older versions of the library.
+ # Please take a look at the explanation of the transformation:
+ # https://stackoverflow.com/questions/990169/how-do-convert-unicode-escape-sequences-to-unicode-characters-in-a-python-string
+
+ if path.startswith('"') and path.endswith('"'):
+ return (path.strip('"').encode('utf8').decode('unicode-escape')
+ .encode('latin-1').decode('utf8'))
+ else:
+ return path
+
+
class Error:
def __init__(self, message, line=None):
self.message = message
@@ -303,14 +321,6 @@ class GitCommit:
'separately from normal commits'))
return
- # check for an encoded utf-8 filename
- hint = 'git config --global core.quotepath false'
- for modified, _ in self.info.modified_files:
- if modified.startswith('"') or modified.endswith('"'):
- self.errors.append(Error('Quoted UTF8 filename, please set: '
- f'"{hint}"', modified))
- return
-
all_are_ignored = (len(project_files) + len(ignored_files)
== len(self.info.modified_files))
self.parse_lines(all_are_ignored)