Re: [PATCH] pre-commit hook should ignore carriage returns at EOL
- Date: Tue, 24 Jun 2008 22:09:06 +0200
- From: Jakub Narebski <jnareb@xxxxxxxxx>
- Subject: Re: [PATCH] pre-commit hook should ignore carriage returns at EOL
On Tue, 24 Jun 2008, Ian Hilt wrote:
> On Tue, 24 Jun 2008 at 12:05pm -0700, Jakub Narebski wrote:
>
> > I don't think so, because you want next to test for whitespace
> > where it _doesn't_ end in \r, i.e. this condition is here
> > because of the 'else' clause. IIRC.
>
> What I'm suggesting is this,
>
> if (/\s\r$/) {
> bad_line("trailing whitespace", $_);
> } else {
> if (/\s$/) {
> bad_line("trailing whitespace", $_);
> }
> }
>
> Why only test for \r when all you want to know is whether there is
> whitespace before \r ? If there isn't whitespace and \r at the end
> of a line, then only test for whitespace at the end of a line.
Unfortunately \r matches \s (is whitespace), so if line ends with CR LF
("\r\n") it wouldn't match first regexp, so it would go to 'else'
clause, where it would match /\s$/ and it shouldn't.
--
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html