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 # Detect case challenges
12 case_challenge
=`git ls-files | tr A-Z a-z | sort | uniq -d`
13 if [ -n "$case_challenge" ]
15 echo >&2 "index contains file names differing only in case."
16 echo >&2 "lowercase names follow:"
17 echo >&2 "$case_challenge"
21 # This is slightly modified from Andrew Morton's Perfect Patch.
22 # Lines you introduce should not have trailing whitespace.
23 # Also check for an indentation that has SP before a TAB.
25 if git-rev-parse
--verify HEAD
2>/dev
/null
27 git-diff-index
-p -M --cached HEAD
--
29 # NEEDSWORK: we should produce a diff with an empty tree here
30 # if we want to do the same verification for the initial import.
36 my $reported_filename = "";
39 my ($why, $line) = @_;
42 print STDERR "* You have some suspicious patch lines:\n";
46 if ($reported_filename ne $filename) {
47 print STDERR "* In $filename\n";
48 $reported_filename = $filename;
50 print STDERR "* $why (line $lineno)\n";
51 print STDERR "$filename:$lineno:$line\n";
54 if (m|^diff --git a/(.*) b/\1$|) {
58 if (/^@@ -\S+ \+(\d+)/) {
70 bad_line("trailing whitespace", $_);
73 bad_line("indent SP followed by a TAB", $_);
75 if (/^([<>])\1{6} |^={7}$/) {
76 bad_line("unresolved merge conflict", $_);