[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1410837769.18787.40.camel@joe-AO725>
Date: Mon, 15 Sep 2014 20:22:49 -0700
From: Joe Perches <joe@...ches.com>
To: Fabian Frederick <fabf@...net.be>
Cc: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/1] checkpatch: check for subject uniqueness in git
repository.
On Mon, 2014-09-15 at 20:43 +0200, Fabian Frederick wrote:
> Adding patch subject uniqueness check in checkpatch --strict mode.
> See Documentation/SubmittingPatches/globally-unique identifier.
Perhaps something like this?
---
scripts/checkpatch.pl | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0c520f7..e19c40b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -622,6 +622,27 @@ sub git_commit_info {
return ($id, $desc);
}
+my @git_commits = ();
+my @previous_subjects = ();
+
+sub check_subject_duplication {
+ my ($subject) = @_;
+
+ if ($check && $#git_commits < 1 && which("git") && -e ".git") {
+ my $output = `git log --no-color --format='%H %s' 2>&1`;
+ $output =~ s/^\s*//gm;
+ @git_commits = split("\n", $output);
+ }
+
+ return 1 if (grep(/^[a-f0-9]{40,40} $subject$/, @git_commits));
+
+ return 2 if (grep(/^$subject$/, @previous_subjects));
+
+ push(@previous_subjects, $subject);
+
+ return 0;
+}
+
$chk_signoff = 0 if ($file);
my @rawlines = ();
@@ -1264,6 +1285,20 @@ sub raw_line {
return $line;
}
+sub get_complete_header {
+ my ($linenr) = @_;
+
+ my $offset = $linenr - 1;
+
+ my $line = $rawlines[$offset++];
+ while (defined $rawlines[$offset] &&
+ $rawlines[$offset] =~ /\s(\S.*)$/) {
+ $line .= $rawlines[$offset++];
+ }
+
+ return $line;
+}
+
sub cat_vet {
my ($vet) = @_;
my ($res, $coded);
@@ -2047,6 +2082,23 @@ sub process {
}
}
+# Check git commit and patch subject duplication
+ if ($in_header_lines && $line =~ /^Subject:/) {
+ my $subject = get_complete_header($linenr);
+ if ($subject =~ /^Subject:\s*(?:\[[^\]]*\])?\s*(.*)$/) {
+ $subject = $1;
+ }
+
+ my $subject_dup = check_subject_duplication($subject);
+ if ($subject_dup == 1) {
+ CHK("NOT_UNIQUE_SUBJECT",
+ "Identical git commit subject found\n" . $herecurr);
+ } elsif ($subject_dup == 2) {
+ CHK("NOT_UNIQUE_SUBJECT",
+ "Identical patch commit subject found\n" . $herecurr);
+ }
+ }
+
# Check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) {
$signoff++;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists