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;
$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";
}
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";
}