From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbbFLDNF (ORCPT ); Thu, 11 Jun 2015 23:13:05 -0400 Received: from smtprelay0087.hostedemail.com ([216.40.44.87]:44356 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751480AbbFLDNC (ORCPT ); Thu, 11 Jun 2015 23:13:02 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2197:2199:2200:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6261:9108:10004:10400:10848:11026:11232:11473:11658:11914:12043:12438:12517:12519:12555:12740:13069:13095:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: pump15_719fa45b63639 X-Filterd-Recvd-Size: 2688 Message-ID: <1434078779.2972.23.camel@perches.com> Subject: Re: diffs in changelogs From: Joe Perches To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Kent Overstreet Date: Thu, 11 Jun 2015 20:12:59 -0700 In-Reply-To: <20150611134006.9df79a893e3636019ad2759e@linux-foundation.org> References: <20150611134006.9df79a893e3636019ad2759e@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-06-11 at 13:40 -0700, Andrew Morton wrote: > People often put diff snippets in changelogs. This causes problems > when one tries to apply a file containing both the changelog and the > diff because patch(1) tries to apply the diff which it found in the > changelog. That > eg, something like > > git show d24a6e1087030b6da | patch -p1 > > will go haywire. > > So can we please have a checkpatch test warning people away from doing > this? > > > patch(1) seems to be really promiscuous in its detection of a patch. I > haven't had much success searching for "^--- " and similar. What works > best for me is searching for "^[whitespace]@@ -". I don't think that's a good test. Coccinelle uses @@ And how did that commit actually get applied? I tried applying it to a new branch checked out at ce2b3f595e1c56639085645e0130426e443008c0, it fails. Anyway, maybe: --- scripts/checkpatch.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 69c4716..2d87e37 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2399,6 +2399,18 @@ sub process { $in_commit_log = 1; } +# Check if the commit log has a diff which confuse patch + + print("icl: <$in_commit_log> line: <$line>\n"); + if ($in_commit_log && + (($line =~ m@^\s+diff\b.*a/[\w/]+@ && + $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) || + $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ || + $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) { + ERROR("DIFF_IN_COMMIT_MSG", + "It seems a diff exists in the commit message. This can confuse patch\n" . $herecurr); + } + # Check if there is UTF-8 in a commit log when a mail header has explicitly # declined it, i.e defined some charset where it is missing. if ($in_header_lines &&