aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-hooks/commit-msg
diff options
context:
space:
mode:
authorPaul Eggert2024-12-23 13:38:51 -0800
committerPaul Eggert2024-12-23 13:40:45 -0800
commit28c420afab6a0944a192c30ff2d5d9e40c88f14f (patch)
tree5dd8e012d3d97acfe2375157d4d0827863028794 /build-aux/git-hooks/commit-msg
parentb1de495eeae9afc8abccd908e5c53c463afdb7dc (diff)
downloademacs-28c420afab6a0944a192c30ff2d5d9e40c88f14f.tar.gz
emacs-28c420afab6a0944a192c30ff2d5d9e40c88f14f.zip
Avoid U+FFFD in commit messages
* build-aux/git-hooks/commit-msg: Also check against U+FFFD REPLACEMENT CHARACTER in commit messages.
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
-rwxr-xr-xbuild-aux/git-hooks/commit-msg13
1 files changed, 12 insertions, 1 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 1eb2560bba2..dace4c7fb66 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -31,6 +31,8 @@ fi
31# Use U+00A2 CENT SIGN to test whether the locale works. 31# Use U+00A2 CENT SIGN to test whether the locale works.
32cent_sign_utf8_format='\302\242\n' 32cent_sign_utf8_format='\302\242\n'
33cent_sign=`printf "$cent_sign_utf8_format"` 33cent_sign=`printf "$cent_sign_utf8_format"`
34replacement_character_utf8_format='\357\277\275\n'
35replacement_character=`printf "$replacement_character_utf8_format"`
34print_at_sign='BEGIN {print substr("'$cent_sign'@", 2)}' 36print_at_sign='BEGIN {print substr("'$cent_sign'@", 2)}'
35at_sign=`$awk "$print_at_sign" </dev/null 2>/dev/null` 37at_sign=`$awk "$print_at_sign" </dev/null 2>/dev/null`
36if test "$at_sign" != @; then 38if test "$at_sign" != @; then
@@ -44,7 +46,12 @@ if test "$at_sign" != @; then
44fi 46fi
45 47
46# Check the log entry. 48# Check the log entry.
47exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" ' 49exec $awk \
50 -v at_sign="$at_sign" \
51 -v cent_sign="$cent_sign" \
52 -v file="$1" \
53 -v replacement_character="$replacement_character" \
54'
48 BEGIN { 55 BEGIN {
49 # These regular expressions assume traditional Unix unibyte behavior. 56 # These regular expressions assume traditional Unix unibyte behavior.
50 # They are needed for old or broken versions of awk, e.g., 57 # They are needed for old or broken versions of awk, e.g.,
@@ -137,6 +144,10 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" '
137 print "Unprintable character in commit message" 144 print "Unprintable character in commit message"
138 status = 1 145 status = 1
139 } 146 }
147 $0 ~ replacement_character {
148 print "Replacement character in commit message"
149 status = 1
150 }
140 151
141 END { 152 END {
142 if (nlines == 0) { 153 if (nlines == 0) {