From 8ce2f63d73f8f3b5fec220448ca060c43733840f Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 7 Sep 2010 23:35:47 +0100 Subject: [PATCH 1/2] [task/git-tools] Solve dependency on the GNU wc --max-line-length option PHPBB3-9808 --- git-tools/hooks/commit-msg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index d6ad57a38a..91951b05c2 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -55,11 +55,12 @@ quit() fi } -if [ "$(wc --max-line-length "$1" | cut -f1 -d" ")" -gt 80 ] +msg=$(grep -nE '.{81,}' "$1"); + +if [ $? -eq 0 ] then echo "The following lines are greater than 80 characters long:\n" >&2; - - grep -nE '.{81,}' "$1" >&2; + echo $msg >&2; quit $ERR_LENGTH; fi From e08e1e0d9a7c529dbec47705beb2a7384a0e4300 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 7 Sep 2010 23:36:33 +0100 Subject: [PATCH 2/2] [task/git-tools] Change the GNU --lines argument to the POSIX -l Changed to awk which handles the formatting differences between the two versions of wc -- BSD version prefixes the output with spaces, the GNU version does not. PHPBB3-9808 --- git-tools/hooks/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index 91951b05c2..a6777ff9c9 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -65,7 +65,7 @@ then quit $ERR_LENGTH; fi -lines=$(wc --lines "$1" | cut -f1 -d" "); +lines=$(wc -l "$1" | awk '{ print $1; }'); expecting=header; in_description=0; in_empty=0;