Skip to contentSkip to conversation

scripts/checkpatch.pl: check for placeholders in cover letter patches

PATCH Superseded Manos Pitsidianakis 2 participants 7 messages Jan 30, 2024 Checkpatch

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/checkpatch.pl: check for placeholders in cover letter patches

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +14 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
 			$non_utf8_charset = 1;
 		}
 
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"
+		if ($in_header_lines &&
+		    $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+		}
+
+		if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+		}
+
 		if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
 		    $rawline =~ /$NON_ASCII_UTF8/) {
 			WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);

base-commit: 11be70677c70fdccd452a3233653949b79e97908

Signature · 1 line
γαῖα πυρί μιχθήτω
#1 lore raw
Quoted 21 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +3 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
 			$non_utf8_charset = 1;
 		}
 
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"

scripts/checkpatch.pl sub process { · line 1665

Quoted 10 lines
scripts/checkpatch.pl +10 -0
+		if ($in_header_lines &&
+		    $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+		}
+
+		if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+		}

Indentation here is totally off

Quoted 9 lines
scripts/checkpatch.pl +1 -0
+
 		if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
 		    $rawline =~ /$NON_ASCII_UTF8/) {
 			WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);

base-commit: 11be70677c70fdccd452a3233653949b79e97908

Signature · 1 line
γαῖα πυρί μιχθήτω

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +0 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
                      $non_utf8_charset = 1;
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 1665

Quoted 13 lines
scripts/checkpatch.pl +13 -0
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"
+             if ($in_header_lines &&
+                 $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+             }
+
+             if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+             }

Indentation here is totally off

It only seems that way because the pre-existing lines use tabs, while I used spaces, according to the QEMU Coding style:

Quoted 19 lines

QEMU indents are four spaces. Tabs are never used, except in Makefiles where they have been irreversibly coded into the syntax.

Quoted 9 lines
scripts/checkpatch.pl +1 -0
+
              if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
                  $rawline =~ /$NON_ASCII_UTF8/) {
                      WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);

base-commit: 11be70677c70fdccd452a3233653949b79e97908 --
γαῖα πυρί μιχθήτω

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw
Quoted 37 lines · Manos Pitsidianakis
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +0 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
                      $non_utf8_charset = 1;
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 1665

Quoted 13 lines
scripts/checkpatch.pl +13 -0
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"
+             if ($in_header_lines &&
+                 $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+             }
+
+             if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+             }

Indentation here is totally off

Quoted 2 lines

It only seems that way because the pre-existing lines use tabs, while I used spaces, according to the QEMU Coding style:

It is more important to be consistent within a single function.

Regardless of that though, the indent is still broken because the body of the 'if' condition is indented /less/ than the 'if' condition itself.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
Quoted 38 lines · Daniel P. Berrangé
Quoted 37 lines · Manos Pitsidianakis
Quoted 35 lines · Daniel P. Berrangé
Quoted 21 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +3 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
                      $non_utf8_charset = 1;
              }
 
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"

scripts/checkpatch.pl sub process { · line 1665

Quoted 10 lines
scripts/checkpatch.pl +10 -0
+             if ($in_header_lines &&
+                 $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+             }
+
+             if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+             }

Indentation here is totally off

Quoted 7 lines
Quoted 2 lines

It only seems that way because the pre-existing lines use tabs, while I used spaces, according to the QEMU Coding style:

It is more important to be consistent within a single function.

Regardless of that though, the indent is still broken because the body of the 'if' condition is indented /less/ than the 'if' condition itself.

Well not really, that's because my editor replaced the tabs when quoting your e-mail.

Anyway, I will respin a v2 with just tabs for indentation right away.

Thanks!

Quoted 7 lines

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw
Quoted 42 lines · Manos Pitsidianakis
Quoted 41 lines · Daniel P. Berrangé
Quoted 39 lines · Manos Pitsidianakis
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +0 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
                      $non_utf8_charset = 1;
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 1665

Quoted 13 lines
scripts/checkpatch.pl +13 -0
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"
+             if ($in_header_lines &&
+                 $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+             }
+
+             if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+             }

Indentation here is totally off

It only seems that way because the pre-existing lines use tabs, while I used spaces, according to the QEMU Coding style:

Quoted 7 lines
Quoted 4 lines

It is more important to be consistent within a single function.

Regardless of that though, the indent is still broken because the body of the 'if' condition is indented /less/ than the 'if' condition itself.

Well not really, that's because my editor replaced the tabs when quoting your e-mail.

The under-indentation of the WARN statement has nothing to do with reply quoting, it is visible in the initial patch you submitted:

https://lists.nongnu.org/archive/html/qemu-devel/2024-01/msg06216.html

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
Quoted 48 lines · Daniel P. Berrangé
Quoted 47 lines · Manos Pitsidianakis
Quoted 45 lines · Daniel P. Berrangé
Quoted 37 lines · Manos Pitsidianakis
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · Manos Pitsidianakis

Check if a file argument is a cover letter patch produced by git-format-patch --cover-letter; It is initialized with subject suffix " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***". If they exist, warn the user.

---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +0 -0
index 7026895074..34f12c9848 100755
@@ -1650,6 +1650,20 @@ sub process {
                      $non_utf8_charset = 1;
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 1665

Quoted 13 lines
scripts/checkpatch.pl +13 -0
+# Check if this is a cover letter patch produced by git-format-patch
+# --cover-letter; It is initialized with subject suffix
+# " *** SUBJECT HERE ***" and body prefix " *** BLURB HERE ***"
+             if ($in_header_lines &&
+                 $rawline =~ /^Subject:.+[*]{3} SUBJECT HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with uninitialized subject" .
+             " '*** SUBJECT HERE ***'\n$hereline\n");
+             }
+
+             if ($rawline =~ /^[*]{3} BLURB HERE [*]{3}\s*$/) {
+        WARN("Patch appears to be a cover letter with leftover placeholder " .
+             "text '*** BLURB HERE ***'\n$hereline\n");
+             }

Indentation here is totally off

Quoted 2 lines

It only seems that way because the pre-existing lines use tabs, while I used spaces, according to the QEMU Coding style:

It is more important to be consistent within a single function.

Regardless of that though, the indent is still broken because the body of the 'if' condition is indented /less/ than the 'if' condition itself.

Quoted 7 lines
Quoted 2 lines

Well not really, that's because my editor replaced the tabs when quoting your e-mail.

The under-indentation of the WARN statement has nothing to do with reply quoting, it is visible in the initial patch you submitted:

https://lists.nongnu.org/archive/html/qemu-devel/2024-01/msg06216.html

The html in that link has expanded tabs to 8 spaces :) And QEMU coding style says an indentation level is 4 spaces.

This is one of the reasons tabs should not be used for indentation at all. It shows up different in different contexts.

Anyway, it's not very important in any case. Besides, I have superseded this patch with a v2.

Thanks,
Manos