git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] hooks--pre-commit.sample: check for chars, that are not allowed for a windows file name

From
Ddexteritas <dexteritas1@gmx.de>
Date
Jun 15, 2016, 08:02 UTC
Message-ID
<0102015553154cde-5c798c87-87c1-4acf-919a-c824dce01fae-000000@eu-west-1.amazonses.com>
After the ASCII-check, test the windows compatibility of file names.
Can be disabled by:
git config hooks.allownonwindowschars true
---
 templates/hooks--pre-commit.sample | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
index 68d62d5..120daf1 100755
--- a/templates/hooks--pre-commit.sample
+++ b/templates/hooks--pre-commit.sample
@@ -17,6 +17,7 @@ fi
 
 # If you want to allow non-ASCII filenames set this variable to true.
 allownonascii=$(git config --bool hooks.allownonascii)
+allownonwindowschars=$(git config --bool hooks.allownonwindowschars)
 
 # Redirect output to stderr.
 exec 1>&2
@@ -43,6 +44,27 @@ If you know what you are doing you can disable this check using:
   git config hooks.allownonascii true
 EOF
 	exit 1
+elif [ "$allownonwindowschars" != "true" ] &&
+	# If you work with linux and windows, there is a problem, if you use
+	# chars like \ / : * ? " < > |
+	# Check if there are used only windows compatible chars
+	test $(git diff --cached --name-only --diff-filter=A -z $against |
+	  LC_ALL=C tr -d '[0-9A-Za-z\[\]\{\}_ -)+-.]\0' | wc -c) != 0
+then
+	cat <<\EOF
+Error: Attempt to add a chars that are not allowed for a windows file name.
+
+This can cause problems if you want to work with people on other platforms.
+
+To be portable it is advisable to rename the file.
+
+Check your filenames for: \ / : * ? " < > |
+
+If you know what you are doing you can disable this check using:
+
+  git config hooks.allownonwindowschars true
+EOF
+	exit 2
 fi
 
 # If there are whitespace errors, print the offending file names and fail.

--
https://github.com/git/git/pull/252
Next: Thomas Braun
Message 1 of 4 in “hooks--pre-commit.sample: check for chars, that are not allowed for a windows file name”
  1. hooks--pre-commit.sample: check for chars, that are not allowed for a windows file namedexteritas, Jun 15, 2016
  2. Thomas BraunJun 15, 2016
  3. dex teritasJun 17, 2016
  4. Junio C HamanoJun 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.