3 # An example hook script to verify what is about to be committed.
4 # Called by git-commit-script with no arguments. The hook should
5 # exit with non-zero status after issuing an appropriate message if
6 # it wants to stop the commit.
8 # To enable this hook, make this file executable.
10 # This is slightly modified from Andrew Morton's Perfect Patch.
11 # Lines you introduce should not have trailing whitespace.
12 # Also check for an indentation that has SP before a TAB.
17 my $reported_filename = "";
20 my ($why, $line) = @_;
23 print STDERR "* You have some suspicious patch lines:\n";
27 if ($reported_filename ne $filename) {
28 print STDERR "* In $filename\n";
29 $reported_filename = $filename;
31 print STDERR "* $why (line $lineno)\n";
32 print STDERR "$filename:$lineno:$line\n";
34 open $fh, "-|", qw(git-diff-cache -p -M --cached HEAD);
36 if (m|^diff --git a/(.*) b/\1$|) {
40 if (/^@@ -\S+ \+(\d+)/) {
52 bad_line("trailing whitespace", $_);
55 bad_line("indent SP followed by a TAB", $_);