[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils
Subject:    Re: [PATCH] scripts: commit-msg: tweak 72-column test to avoid a false-positive
From:       Jim Meyering <jim () meyering ! net>
Date:       2011-11-23 8:06:23
Message-ID: 87fwhf6z5s.fsf () rho ! meyering ! net
[Download RAW message or body]

Jim Meyering wrote:

> I have just had this commit hook mistakenly reject a commit log
> due to a git-generated comment line that was longer than 72.
> Obviously, those should be exempted:
>
...
> -      72 < length $line
> +      72 < length $line && $line =~ /^#/

Glad I didn't push that.
Here's the right one:

>From 0fd74a564eec0d1bd152ca7b6d5967ff571be66a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 23 Nov 2011 09:02:51 +0100
Subject: [PATCH] scripts: commit-msg: tweak 72-column test to avoid a
 false-positive

* scripts/git-hooks/commit-msg: Don't warn about a line that is
longer than 72 if it is a comment.  Git-generated comments would
occasionally trigger this.
---
 scripts/git-hooks/commit-msg |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/git-hooks/commit-msg b/scripts/git-hooks/commit-msg
index 7d0891e..22f595f 100755
--- a/scripts/git-hooks/commit-msg
+++ b/scripts/git-hooks/commit-msg
@@ -101,7 +101,7 @@ sub check_msg($$)
   # Limit line length to allow for the ChangeLog's leading TAB.
   foreach my $line (@line)
     {
-      72 < length $line
+      72 < length $line && $line =~ /^[^#]/
         and return 'line longer than 72';
     }

--
1.7.8.rc3.23.ge14d6


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic