{"id":68,"date":"2007-07-13T16:11:22","date_gmt":"2007-07-13T15:11:22","guid":{"rendered":"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/13\/git-on-windows-you-have-some-suspicious-patch-lines\/"},"modified":"2008-10-10T12:53:30","modified_gmt":"2008-10-10T11:53:30","slug":"git-on-windows-you-have-some-suspicious-patch-lines","status":"publish","type":"post","link":"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/13\/git-on-windows-you-have-some-suspicious-patch-lines\/","title":{"rendered":"Git on Windows: &#8220;You have some suspicious patch lines&#8221;"},"content":{"rendered":"<div style=\"border-style: dashed; border-width: 1px; margin-top: 14px;padding: 4px; background: #f0f0f0;\"><strong>Update 2008-04-24:<\/strong> as commenter Jakub Narebski correctly points out,  it should be better to use <em>core.autocrlf<\/em> and crlf attribute for resolving this issue, but I have had no chance to test this up to now. The solution below is still valid, but more of the sort of an ugly hack.<\/div>\n<div style=\"border-style: dashed; border-width: 1px; margin-top: 14px;padding: 4px; background: #f0f0f0;\"><strong>Update 2008-06-11:<\/strong> I have stopped using this solution and only use &#8220;git-config core.autocrlf true&#8221; and &#8220;git-config core.safecrlf true&#8221; any more. It works reliably and is exactly what I need and not such an ugly hack.<\/div>\n<div style=\"border-style: dashed; border-width: 1px; margin-top: 14px;padding: 4px; background: #f0f0f0;\"><strong>Update 2008-06-22:<\/strong> Well, of course you can still get &#8220;You have some suspicious patch lines&#8221; if you follow the core.autocrlf approach&#8230; but this time it really means you have trailing whitespace, not just line-breaks. If you really don&#8217;t care about trailing white-space at all, my initial solution is still valid, as it simply disables this check.<\/div>\n<p>If you are using <a href=\"http:\/\/git.or.cz\/\">Git<\/a> under Windows using <a href=\"http:\/\/www.cygwin.com\/\">cygwin<\/a>, and you got through the <a href=\"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/06\/git-and-windows-vista\/\">initial problems<\/a>, you will soon realize that Git likes to fail with &#8220;You have some suspicious patch lines&#8221; when committing.<\/p>\n<p>The cause for this problem is the carriage-return\/line-feed problem of Git under Windows\/cygwin: The patches contain a trailing line-feed if you edited them with a Windows editor and not strictly inside cygwin.  This will trigger the pre-commit hook to fail on patches where the last line of a file has been changed.<\/p>\n<p>To solve the problem, you need to edit <code>.git\/hooks\/pre-commit<\/code> and comment out the following lines:<\/p>\n<blockquote><p><code>if (\/\\s$\/) {<br \/>\nbad_line(\"trailing whitespace\", $_);<br \/>\n}<\/code><\/p><\/blockquote>\n<p>Now committing should work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update 2008-04-24: as commenter Jakub Narebski correctly points out, it should be better to use core.autocrlf and crlf attribute for resolving this issue, but I have had no chance to test this up to now. The solution below is still valid, but more of the sort of an ugly hack. Update 2008-06-11: I have stopped &hellip; <a href=\"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/13\/git-on-windows-you-have-some-suspicious-patch-lines\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Git on Windows: &#8220;You have some suspicious patch lines&#8221;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[131,56,14],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-development","category-software","tag-git","tag-troubleshooting","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":2,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/68\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}