From: Greg Kroah-Hartman Date: Mon, 12 Nov 2018 19:44:34 +0000 (-0800) Subject: scripts/c2p: update to my latest version X-Git-Tag: v4.19.2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=904d0d6e5c0cf8a2b90bfcd6ef3ffc7d32a79981;p=thirdparty%2Fkernel%2Fstable-queue.git scripts/c2p: update to my latest version --- diff --git a/scripts/c2p b/scripts/c2p index 208c7b12ab5..9575cfb8881 100755 --- a/scripts/c2p +++ b/scripts/c2p @@ -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 = ) { - # 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 = ) { } 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"; }