[coreboot-gerrit] Patch set updated for coreboot: 6802fea lint: Add check for non-ASCII file names

Paul Menzel (paulepanter@users.sourceforge.net) gerrit at coreboot.org
Thu May 30 14:38:46 CEST 2013


Paul Menzel (paulepanter at users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3336

-gerrit

commit 6802fead04d570a404b8294180a34b8e51e620c2
Author: Paul Menzel <paulepanter at users.sourceforge.net>
Date:   Thu May 30 00:36:29 2013 +0200

    lint: Add check for non-ASCII file names
    
    The sample pre-commit hook shipped by git includes a test for non-
    ASCII file names. Use it.
    
    This test should probably be added under `util/lint` in a separate
    file.
    
    Change-Id: Iad09ab62620b68e652cf55dc3f6d2033075989fb
    Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
---
 util/gitconfig/pre-commit | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/util/gitconfig/pre-commit b/util/gitconfig/pre-commit
index 8ab3e56..102425d 100755
--- a/util/gitconfig/pre-commit
+++ b/util/gitconfig/pre-commit
@@ -1,2 +1,34 @@
 #!/bin/sh
-exec make lint-stable
+
+# If you want to allow non-ascii filenames set this variable to true.
+allownonascii=$(git config hooks.allownonascii)
+
+# Redirect output to stderr.
+exec 1>&2
+
+# Cross platform projects tend to avoid non-ascii filenames; prevent
+# them from being added to the repository. We exploit the fact that the
+# printable range starts at the space character and ends with tilde.
+if [ "$allownonascii" != "true" ] &&
+	# Note that the use of brackets around a tr range is ok here, (it's
+	# even required, for portability to Solaris 10's /usr/bin/tr), since
+	# the square bracket bytes happen to fall in the designated range.
+	test $(git diff --cached --name-only --diff-filter=A -z $against |
+	  LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
+then
+	echo "Error: Attempt to add a non-ascii file name."
+	echo
+	echo "This can cause problems if you want to work"
+	echo "with people on other platforms."
+	echo
+	echo "To be portable it is advisable to rename the file ..."
+	echo
+	echo "If you know what you are doing you can disable this"
+	echo "check using:"
+	echo
+	echo "  git config hooks.allownonascii true"
+	echo
+	exit 1
+fi
+
+make lint-stable



More information about the coreboot-gerrit mailing list