mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-26 06:57:59 +00:00
scripts: sync git-hooks from coreutils
This commit is contained in:
parent
fc62345ebc
commit
61c1fffe7b
@ -10,6 +10,6 @@
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
test -x "$GIT_DIR/hooks/commit-msg" &&
|
||||
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
|
||||
:
|
||||
|
||||
@ -16,7 +16,7 @@ $editor = "vi" if $? != 0 or $editor =~ /^\s*\z/;
|
||||
my @valid = qw(
|
||||
diff diff3 cmp sdiff
|
||||
|
||||
gnulib tests maint doc build scripts
|
||||
all gnulib tests maint doc build scripts
|
||||
);
|
||||
my $v_or = join '|', @valid;
|
||||
my $valid_regex = qr/^(?:$v_or)$/;
|
||||
@ -79,7 +79,7 @@ sub check_msg($$)
|
||||
my ($log_file, $line_ref) = @_;
|
||||
|
||||
local *LOG;
|
||||
open LOG, '<', $log_file
|
||||
open LOG, '<:utf8', $log_file
|
||||
or return "failed to open for reading: $!";
|
||||
@$line_ref = <LOG>;
|
||||
close LOG;
|
||||
@ -109,21 +109,24 @@ sub check_msg($$)
|
||||
and return 'second line must be empty';
|
||||
|
||||
# Limit line length to allow for the ChangeLog's leading TAB.
|
||||
my $max_len = 72;
|
||||
foreach my $line (@line)
|
||||
{
|
||||
72 < length $line && $line =~ /^[^#]/
|
||||
and return 'line longer than 72';
|
||||
last if $line =~ '.*-{24} >8 -{24}$';
|
||||
my $len = length $line;
|
||||
$max_len < $len && $line =~ /^[^#]/
|
||||
and return "line length ($len) greater than than max: $max_len";
|
||||
}
|
||||
|
||||
my $buf = join ("\n", @line) . "\n";
|
||||
$buf =~ m!https?://bugzilla\.redhat\.com/show_bug\.cgi\?id=(\d+)!s
|
||||
and return "use shorter http://bugzilla.redhat.com/$1";
|
||||
and return "use shorter https://bugzilla.redhat.com/$1";
|
||||
|
||||
$buf =~ m!https?://debbugs\.gnu\.org/(?:cgi/bugreport\.cgi\?bug=)?(\d+)!s
|
||||
and return "use shorter http://bugs.gnu.org/$1";
|
||||
and return "use shorter https://bugs.gnu.org/$1";
|
||||
|
||||
$buf =~ /^ *Signed-off-by:/mi
|
||||
and return q(do not use "Signed-off-by:");
|
||||
$buf =~ m!https://lists\.gnu\.org/archive/html/!s
|
||||
and return "use '/r/' in place of '/archive/html/' in lists.gnu.org URLs";
|
||||
|
||||
return '';
|
||||
}
|
||||
@ -141,6 +144,7 @@ sub check_msg($$)
|
||||
$err eq ''
|
||||
and last;
|
||||
$err = "$ME: $err\n";
|
||||
-t STDOUT or die $err;
|
||||
warn $err;
|
||||
# Insert the diagnostic as a comment on the first line of $log_file.
|
||||
rewrite $log_file, $err, \@line;
|
||||
|
||||
@ -9,6 +9,6 @@
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
test -x "$GIT_DIR/hooks/pre-commit" &&
|
||||
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
|
||||
:
|
||||
|
||||
@ -15,13 +15,13 @@ else
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
# If you want to allow non-ascii filenames set this variable to true.
|
||||
allownonascii=$(git config hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# Cross platform projects tend to avoid non-ascii filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
@ -31,17 +31,18 @@ if [ "$allownonascii" != "true" ] &&
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII 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.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
echo "Error: Attempt to add a non-ascii file name."
|
||||
echo
|
||||
echo "This can cause problems if you want to work"
|
||||
echo "with people on other platforms."
|
||||
echo
|
||||
echo "To be portable it is advisable to rename the file ..."
|
||||
echo
|
||||
echo "If you know what you are doing you can disable this"
|
||||
echo "check using:"
|
||||
echo
|
||||
echo " git config hooks.allownonascii true"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user