5 my $reported_filename = "";
8 if (scalar @ARGV > 0) {
14 exit(0) if (system("git-rev-parse --verify HEAD 2>/dev/null"));
15 open(PATCH, "git-diff-index -p -M --cached HEAD --|") ||
16 die("git-diff-index failed");
18 check_file($1) if (m|^diff --git a/(.*\.[ch]) b/\1$|);
26 my ($why, $line) = @_;
29 print STDERR "* You have some suspicious patch lines:\n";
33 if ($reported_filename ne $filename) {
34 print STDERR "* In $filename\n";
35 $reported_filename = $filename;
37 print STDERR "* \t$why\n";
38 print STDERR "$lineno:$line\n" if ($line);
44 open(IN, "$filename") || die ("Cannot open $filename");
53 if (/^\s*\#include\s+"/) {
54 bad_line("sherlock includes after global includes", $_) if (!$has_loc && $has_glob);
58 bad_line("trailing whitespace", $_);
61 bad_line("indent SP followed by a TAB", $_);
63 if (/^\s*\#define\s+LOCAL_DEBUG/) {
64 bad_line("LOCAL_DEBUG left enabled", $_);
66 if (/^([<>])\1{6} |^={7}$/) {
67 bad_line("unresolved merge conflict", $_);
70 $has_glob++ if (/^\s*\#include\s+\</);
71 $has_copy++ if (/\([Cc]\)\s*\w/);
72 $empty = $_ =~ /^\s*$/;
75 bad_line("empty lines at end of input") if ($empty);
76 bad_line("missing copyright") if (!$has_copy);