3 # An example hook script to verify what is about to be committed.
4 # Called by git-commit 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.
14 if git-rev-parse --verify HEAD 2>/dev/null
16 git-diff-index -p -M --cached HEAD --
18 # NEEDSWORK: we should produce a diff with an empty tree here
19 # if we want to do the same verification for the initial import.
25 my $reported_filename = "";
28 my ($why, $line) = @_;
31 print STDERR "* You have some suspicious patch lines:\n";
35 if ($reported_filename ne $filename) {
36 print STDERR "* In $filename\n";
37 $reported_filename = $filename;
39 print STDERR "* $why (line $lineno)\n";
40 print STDERR "$filename:$lineno:$line\n";
43 if (m|^diff --git a/(.*) b/\1$|) {
47 if (/^@@ -\S+ \+(\d+)/) {
59 bad_line("trailing whitespace", $_);
62 bad_line("indent SP followed by a TAB", $_);
64 if (/^(?:[<>=]){7}/) {
65 bad_line("unresolved merge conflict", $_);