]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
scripts/c2p: update to my latest version
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Nov 2018 19:44:34 +0000 (11:44 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Nov 2018 19:44:34 +0000 (11:44 -0800)
scripts/c2p

index 208c7b12ab5313b9d2997d9f4d872983150ef8c8..9575cfb8881797c8645eaf6989273eff18ec290b 100755 (executable)
@@ -13,6 +13,7 @@ my $git_id;
 my $header_complete = "false";
 my $signed_off_by_seen = "false";
 my $signed_off_by_complete = "false";
+my $eat_subject_trailer = "false";
 my $tmpfile;
 my $kernel_version;
 
@@ -48,14 +49,33 @@ if (!defined($kernel_version)) {
 
 $tmpfile = `mktemp patch.XXXXX` || die "Failed to run mktemp";
 chomp($tmpfile);
-$from = `git show --pretty=email $base_id | head -n 2 | grep "From: "` || die "Failed to run git";
+
+# if we were smart, we could just reconstruct the header the way we want to
+# with a format: string, but we are not, so let's parse the thing out...
+$from = `git show --pretty=format:"%aN <%ae>" $base_id | head -n 1` || die "Failed to run git to get from";
+$subj = `git show --pretty=format:"Subject: %s" $base_id | head -n 1` || die "Failed to run git to get subject";
 
 open FILE, ">$tmpfile" || die "Failed to create $tmpfile";
 open GIT, "git show --pretty=email $base_id |" || die "Failed to run git";
 
 while ($line = <GIT>) {
-       # clean up the subject line, stripping off the [PATCH] prefix
-       $line =~ s/^Subject: \[PATCH\]/Subject:/;
+
+       # subjects have the fun ability to line-wrap, but we handled that above
+       # when we grabbed the "raw" subject, so just ignore trailing subject
+       # lines.
+       if ($eat_subject_trailer eq "true") {
+               $eat_subject_trailer = "false";
+               if ($line =~m/^ /) {
+                       # eat this line
+                       next;
+               }
+       }
+
+       # If this is the subject line, use our own.
+       if ($line =~m/^Subject: /) {
+               $line = $subj;
+               $eat_subject_trailer = "true";
+       }
 
        if ($line =~m/^Signed-off-by:/) {
                $signed_off_by_seen = "true";
@@ -81,7 +101,7 @@ while ($line = <GIT>) {
        }
        if ($header_complete eq "false") {
                if ($line eq "\n") {
-                       print FILE "$from\n";
+                       print FILE "From: $from\n";
                        print FILE "commit $git_id upstream.\n\n";
                        $header_complete = "true";
                }