diff options
| author | Paul Eggert | 2024-12-23 13:38:51 -0800 |
|---|---|---|
| committer | Paul Eggert | 2024-12-23 13:40:45 -0800 |
| commit | 28c420afab6a0944a192c30ff2d5d9e40c88f14f (patch) | |
| tree | 5dd8e012d3d97acfe2375157d4d0827863028794 /build-aux/git-hooks/commit-msg | |
| parent | b1de495eeae9afc8abccd908e5c53c463afdb7dc (diff) | |
| download | emacs-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-x | build-aux/git-hooks/commit-msg | 13 |
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. |
| 32 | cent_sign_utf8_format='\302\242\n' | 32 | cent_sign_utf8_format='\302\242\n' |
| 33 | cent_sign=`printf "$cent_sign_utf8_format"` | 33 | cent_sign=`printf "$cent_sign_utf8_format"` |
| 34 | replacement_character_utf8_format='\357\277\275\n' | ||
| 35 | replacement_character=`printf "$replacement_character_utf8_format"` | ||
| 34 | print_at_sign='BEGIN {print substr("'$cent_sign'@", 2)}' | 36 | print_at_sign='BEGIN {print substr("'$cent_sign'@", 2)}' |
| 35 | at_sign=`$awk "$print_at_sign" </dev/null 2>/dev/null` | 37 | at_sign=`$awk "$print_at_sign" </dev/null 2>/dev/null` |
| 36 | if test "$at_sign" != @; then | 38 | if test "$at_sign" != @; then |
| @@ -44,7 +46,12 @@ if test "$at_sign" != @; then | |||
| 44 | fi | 46 | fi |
| 45 | 47 | ||
| 46 | # Check the log entry. | 48 | # Check the log entry. |
| 47 | exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" ' | 49 | exec $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) { |