Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit You have some suspicious patch lines

Tags:

git

git commit giving me the following message

*
* You have some suspicious patch lines:
*
* In projects/bong/traid/apps/controller/project.php
* trailing whitespace (line 220)
projects/bong/traid/apps/controller/project.php:220:        
* trailing whitespace (line 223)

What does that mean ?

like image 413
Neel Basu Avatar asked Dec 29 '10 17:12

Neel Basu


3 Answers

That happens when the file has trailing whitespace, if you run:

git commit --no-verify

it will commit ok. ref

like image 126
andrebola Avatar answered Sep 27 '22 21:09

andrebola


I find it disturbing to just deactivate pre-commit altogether. If you have a look at the content of .git/hooks/pre-commit, it also checks for unresolved merge conflicts, and I would like to continue to check for those!

Towards the end of the file it runs some regular expressions that check for spaces at line endings and untidy tab characters. I just commented out these lines so it doesn't look for those, and I got rid of the pre-commit warning problem.


 55     if (s/^\+//) {
 56         $lineno++;
 57         chomp;
 **58         # if (/\s$/) {
 59         # bad_line("trailing whitespace", $_);
 60         # }
 61         # if (/^\s* \t/) {
 62         # bad_line("indent SP followed by a TAB", $_);
 63         # }**
 64         if (/^([])\1{6} |^={7}$/) {
 65         bad_line("unresolved merge conflict", $_);
 66         }
 67     }
like image 24
Greg Robbins Avatar answered Sep 27 '22 22:09

Greg Robbins


In short, it means that you have trailing white space on the lines mentioned. Trailing white is a bit of an odd choice, and sometimes is a compiler error or other error waiting to happen.

You can either clean up those lines, or you can force the commit just this time by adding the --no-verify flag to your git commit.

Alternatively, you can just turn off this checking by disabling pre-commit hooks, like this: cd .git/hooks/ chmod -x pre-commit

BTW, this answer is extracted from: http://danklassen.com/wordpress/2008/12/git-you-have-some-suspicious-patch-lines/

like image 43
Joshua D. Boyd Avatar answered Sep 27 '22 22:09

Joshua D. Boyd