From 06abe8cbc73e43426b1aa983331dde5c36460c0a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 5 Mar 2014 00:26:26 +0100 Subject: [PATCH] Check file given as first argument Check the file whose name has been specified on the command line for errors, instead of `stdin'. Git passes the file name of the file containing the commit message instead of passing the commit message to `stdin'. This was supposed to be committed in the first commit. but somehow it got lost. --- commit-check | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commit-check b/commit-check index 6543633..3cfd7c6 100755 --- a/commit-check +++ b/commit-check @@ -12,7 +12,9 @@ sub err { $status = 1; } -while (<>) { +open(my $commitfile, "<", $ARGV[0]) or die "Couldn't open $ARGV[0]"; + +while (<$commitfile>) { next if /^#/; # Discard comments next if $lineno == 0 && /^$/; # Discard leading empty lines $lineno++; # Start at 1, so increment first @@ -27,4 +29,5 @@ while (<>) { err "Longer than 80 characters" if /^.{73,}/; } +close $commitfile; exit $status;