threads / discuss / 14587

Error: "You have some suspicious patch lines"

Subject: Error: "You have some suspicious patch lines"

## tl;dr

3 messages between Jul 22, 2008 and Jul 22, 2008.

replies: 2people: 3as markdown or json

Ben Aurel· Jul 22, 2008, 07:16 UTC · lore
hi

I working on mac os x 10.5.4 (intel) with git version 1.5.5.3 and I always get this message for most of my perl scripts and also for "Makefile.pre" files:

----------- Message ---------------
* You have some suspicious patch lines:
*
* In src/scripts/trunk/3rdparty/file_sanity.pl
* trailing whitespace (line 52)
...
------------------------------------------

Editing '.git/hooks/pre-commit' and comment out the following lines (around line 58):

-- 58 if (/\s$/) { 59 bad_line("trailing whitespace", $_); 60 } --

I still have this message
----------- Message ---------------
$ git commit .
*
* You have some suspicious patch lines:
*
* In src/scripts/trunk/3rdparty/file_sanity.pl
* indent SP followed by a TAB (line 112)
-----------------------------------------
Editing '.git/hooks/pre-commit' and comment out the following lines
--
 61             if (/^\s* \t/) {
 62                 bad_line("indent SP followed by a TAB", $_);
 63             }
--
And finally "git commit" works again.

The question now is: Is it really necessary to edit the git script everytime? Is there a urgent reason why git refuses to commit because of "suspicious" lines? Is it really necessary?

Thanks ben

Jeff King· Jul 22, 2008, 07:26 UTC · re: Ben Aurel · lore

Re: Error: "You have some suspicious patch lines"

On Tue, Jul 22, 2008 at 09:16:44AM +0200, Ben Aurel wrote:
Show 14 quoted lines
> -----------------------------------------
>
> Editing '.git/hooks/pre-commit' and comment out the following lines
> --
> 61             if (/^\s* \t/) {
> 62                 bad_line("indent SP followed by a TAB", $_);
> 63             }
> --
>
> And finally "git commit" works again.
>
> The question now is: Is it really necessary to edit the git script  
> everytime? Is there a urgent reason why git refuses to commit because of  
> "suspicious" lines? Is it really necessary?

The pre-commit hook that ships with git checks whitespace as an example of what one _could_ do with hooks. It is not meant to be enabled by default (unless you want that whitespace checking).

So either:
 1. You enabled it by setting the execute bit. If so, then don't do
    that.
 2. Something is broken, and it has caused the hook to be enabled
    accidentally. I recall somebody complaining that hooks were enabled
    by default under cygwin because the filesystem didn't support the
    execute bit. Are you working on an exec-bit challenged filesystem?

In newer versions of git, the hooks actually ship with a .sample extension so that they will not be used accidentally, regardless of the executable bit. In the meantime, it is safe to simply delete .git/hooks/pre-commit if it is bothering you.

-Peff
Jakub Narebski· Jul 22, 2008, 09:13 UTC · re: Ben Aurel · lore

Re: Error: "You have some suspicious patch lines"

Ben Aurel <ben.aurel@gmail.com> writes:
Show 11 quoted lines
> I working on mac os x 10.5.4 (intel) with git version 1.5.5.3 and I
> always get this message for most of my perl scripts and also for
> "Makefile.pre" files:
> 
> ----------- Message ---------------
> * You have some suspicious patch lines:
> *
> * In src/scripts/trunk/3rdparty/file_sanity.pl
> * trailing whitespace (line 52)
> ...
> ------------------------------------------
> The question now is: Is it really necessary to edit the git script
> everytime? Is there a urgent reason why git refuses to commit because
> of "suspicious" lines? Is it really necessary?

.git/hooks/pre-commit is example hook which helps to keep Coding Style, and prevents from accidentally comitting nonresolved file-level merge conflict (file with conflict markers).

If you want to skip running this hook once (or once upon a time), you can use '-n'/'--no-verify' option to "git commit". Or you can turn this example hook off, either by removing execute permission from it, by removing it alltogether (you can still find it in templates, usually at /usr/share/git-core/templates/hooks/pre-commit), or rename it adding for example '.sample' or '.nonactive' suffix.

This hook should not be turned on by default, but if your filesystem is executing bit challenged it could be turned on at repository creation time unintentionally. Newer version of git use '.sample' suffix (for example pre-commit.sample) instead of relying on not always reliable execute bit being unset.

HTH
-- 
Jakub Narebski
Poland
ShadeHawk on #git

← back to recent threads