git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Julian Prein via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Julian Prein <druckdev@protonmail.com>,
	Julian Prein <druckdev@protonmail.com>
Subject: [PATCH] hooks--pre-commit: detect non-ASCII when renaming
Date: Thu, 14 Jul 2022 22:17:53 +0000	[thread overview]
Message-ID: <pull.1291.git.git.1657837073372.gitgitgadget@gmail.com> (raw)

From: Julian Prein <druckdev@protonmail.com>

Currently the diff-filter that is used to check for non-ASCII characters
in filenames only checks new additions.

Extend the diff-filter in the pre-commit sample to include `CR` as well.
This way non-ASCII character in filenames are detected on a rename/copy
as well.

Signed-off-by: Julian Prein <druckdev@protonmail.com>
---
    hooks--pre-commit: detect non-ASCII when renaming

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1291%2Fdruckdev%2Fpre-commit-renames-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1291/druckdev/pre-commit-renames-v1
Pull-Request: https://github.com/git/git/pull/1291

 templates/hooks--pre-commit.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
index e144712c85c..95c327832da 100755
--- a/templates/hooks--pre-commit.sample
+++ b/templates/hooks--pre-commit.sample
@@ -28,7 +28,7 @@ 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 |
+	test $(git diff --cached --name-only --diff-filter=ACR -z $against |
 	  LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
 then
 	cat <<\EOF

base-commit: bbea4dcf42b28eb7ce64a6306cdde875ae5d09ca
-- 
gitgitgadget

             reply	other threads:[~2022-07-14 22:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 22:17 Julian Prein via GitGitGadget [this message]
2022-07-14 23:03 ` [PATCH] hooks--pre-commit: detect non-ASCII when renaming Junio C Hamano
2022-07-14 23:08   ` Junio C Hamano
2023-11-30 16:13 ` [PATCH v2] " Julian Prein via GitGitGadget
2023-12-03 13:15   ` 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=pull.1291.git.git.1657837073372.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=druckdev@protonmail.com \
    --cc=git@vger.kernel.org \
    /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).