+if ($signoff) {
+ $signoff = "Signed-off-by: " . `git-var GIT_COMMITTER_IDENT`;
+ $signoff =~ s/>.*/>/;
+ $signoff_pattern = quotemeta($signoff);
+}
+
+my @weekday_names = qw(Sun Mon Tue Wed Thu Fri Sat);
+my @month_names = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+
+sub show_date {
+ my ($time, $tz) = @_;
+ my $minutes = abs($tz);
+ $minutes = int($minutes / 100) * 60 + ($minutes % 100);
+ if ($tz < 0) {
+ $minutes = -$minutes;
+ }
+ my $t = $time + $minutes * 60;
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($t);
+ return sprintf("%s %s %d %02d:%02d:%02d %d %+05d",
+ $weekday_names[$wday],
+ $month_names[$mon],
+ $mday, $hour, $min, $sec,
+ $year+1900, $tz);
+}
+
+print "From nobody Mon Sep 17 00:00:00 2001\n";
+open FH, "git stripspace <$commsg |" or die "open $commsg pipe";
+while (<FH>) {
+ unless ($done_header) {
+ if (/^$/) {
+ $done_header = 1;
+ }
+ elsif (/^author (.*>) (.*)$/) {
+ my ($author_ident, $author_date) = ($1, $2);
+ my ($utc, $off) = ($author_date =~ /^(\d+) ([-+]?\d+)$/);
+ $author_date = show_date($utc, $off);
+
+ print "From: $author_ident\n";
+ print "Date: $author_date\n";
+ }
+ next;
+ }
+ unless ($done_subject) {
+ unless ($keep_subject) {
+ s/^\[PATCH[^]]*\]\s*//;
+ s/^/[PATCH$num] /;
+ }
+ if ($headers) {
+ print "$headers\n";
+ }
+ print "Subject: $_";
+ if ($mimemagic) {
+ print "MIME-Version: 1.0\n";
+ print "Content-Type: multipart/mixed;\n";
+ print " boundary=\"------------$mimemagic\"\n";
+ print "\n";
+ print "This is a multi-part message in MIME format.\n";
+ print "--------------$mimemagic\n";
+ print "Content-Type: text/plain; charset=UTF-8; format=fixed\n";
+ print "Content-Transfer-Encoding: 8bit\n";
+ }
+ $done_subject = 1;
+ next;
+ }
+ unless ($done_separator) {
+ print "\n";
+ $done_separator = 1;
+ next if (/^$/);
+ }
+
+ $last_was_signoff = 0;
+ if (/Signed-off-by:/i) {
+ if ($signoff ne "" && /Signed-off-by:\s*$signoff_pattern$/i) {
+ $signoff_seen = 1;
+ }
+ }
+ print $_;
+}
+if (!$signoff_seen && $signoff ne "") {
+ if (!$last_was_signoff) {
+ print "\n";
+ }
+ print "$signoff\n";
+}
+print "\n---\n\n";
+close FH or die "close $commsg pipe";
+' "$keep_subject" "$num" "$signoff" "$headers" "$mimemagic" $commsg
+
+ git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary
+ echo
+ case "$mimemagic" in
+ '');;
+ *)
+ echo "--------------$mimemagic"
+ echo "Content-Type: text/x-patch;"
+ echo " name=\"$commit.diff\""
+ echo "Content-Transfer-Encoding: 8bit"
+ echo "Content-Disposition: inline;"
+ echo " filename=\"$commit.diff\""
+ echo
+ esac
+ git-diff-tree -p $diff_opts "$commit"
+ case "$mimemagic" in
+ '')
+ echo "-- "
+ echo "@@GIT_VERSION@@"