git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dex teritas <dexteritas1@gmx.de>
To: Thomas Braun <thomas.braun@virtuell-zuhause.de>, git@vger.kernel.org
Subject: Re: [PATCH] hooks--pre-commit.sample: check for chars, that are not allowed for a windows file name
Date: Sat, 18 Jun 2016 00:24:04 +0200	[thread overview]
Message-ID: <0Lyj4F-1bQz0I1R2N-016Asy@mail.gmx.com> (raw)
In-Reply-To: <5c02cc24-f68d-6eb3-9759-ffff328a0c2f@virtuell-zuhause.de>

Am 15.06.2016 um 13:15 schrieb Thomas Braun:
> Am 15.06.2016 um 10:02 schrieb dexteritas:
>> 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.
> There are some cases of illegal file names missing. E.g. reserved names,
> trailing period and space. My trial with a precommit hook for avoiding
> illegal filenames on windows can be found at [1]. Feel free to loot my
> version for a reroll.
>
> [1]:
> https://github.com/t-b/git-pre-commit-hook-windows-filenames/blob/master/pre-commit
>
You're right. Thanks for the example.

  reply	other threads:[~2016-06-17 22:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  8:02 [PATCH] hooks--pre-commit.sample: check for chars, that are not allowed for a windows file name dexteritas
2016-06-15 11:15 ` Thomas Braun
2016-06-17 22:24   ` dex teritas [this message]
2016-06-15 17:54 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0Lyj4F-1bQz0I1R2N-016Asy@mail.gmx.com \
    --to=dexteritas1@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=thomas.braun@virtuell-zuhause.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).