aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-12-21 10:35:11 +0100
committerMartin Liska <mliska@suse.cz>2020-12-21 10:35:11 +0100
commit1b021bbd85a79c9d16c1359cbc23b608685dfd9f (patch)
tree950a945106f0ae8babc89410e60dfae1a6141ee0
parent2ebe7526584ed81d70d004d4fd527ef86af367c3 (diff)
downloadgcc-1b021bbd85a79c9d16c1359cbc23b608685dfd9f.zip
gcc-1b021bbd85a79c9d16c1359cbc23b608685dfd9f.tar.gz
gcc-1b021bbd85a79c9d16c1359cbc23b608685dfd9f.tar.bz2
gcc-changelog: new error for quoted utf8 filenames
contrib/ChangeLog: * gcc-changelog/git_commit.py: Add new error for quoted filenames. * gcc-changelog/test_email.py: Test it. * gcc-changelog/test_patches.txt: Test it.
-rwxr-xr-xcontrib/gcc-changelog/git_commit.py8
-rwxr-xr-xcontrib/gcc-changelog/test_email.py4
-rw-r--r--contrib/gcc-changelog/test_patches.txt27
3 files changed, 39 insertions, 0 deletions
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 01f4987..f9cb8cb 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -299,6 +299,14 @@ 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)
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 7ba2fcf..2053531 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -399,3 +399,7 @@ class TestGccChangelog(unittest.TestCase):
def test_unicode_chars_in_filename(self):
email = self.from_patch_glob('0001-Add-horse.patch')
assert not email.errors
+
+ def test_bad_unicode_chars_in_filename(self):
+ email = self.from_patch_glob('0001-Add-horse2.patch')
+ assert email.errors[0].message.startswith('Quoted UTF8 filename')
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index bc93cce..ffd1368 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3371,4 +3371,31 @@ index 00000000000..56c67f58752
+I'm a horse.
--
2.29.2
+=== 0001-Add-horse2.patch ===
+From 2884248d07e4e2c922e137365253e2e521c425b0 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 21 Dec 2020 10:14:46 +0100
+Subject: [PATCH] Add horse.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+ChangeLog:
+
+ * koníček.txt: New file.
+---
+ "kon\303\255\304\215ek.txt" | 1 +
+ 1 file changed, 1 insertion(+)
+ create mode 100644 "kon\303\255\304\215ek.txt"
+
+diff --git "a/kon\303\255\304\215ek.txt" "b/kon\303\255\304\215ek.txt"
+new file mode 100644
+index 00000000000..56c67f58752
+--- /dev/null
++++ "b/kon\303\255\304\215ek.txt"
+@@ -0,0 +1 @@
++I'm a horse.
+--
+2.29.2
+