git commit You have some suspicious patch lines
git com开发者_运维知识库mit
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 ?
That happens when the file has trailing whitespace, if you run:
git commit --no-verify
it will commit ok. ref
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 }
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/
精彩评论