use Getopt::Long;
use IO::File;
use File::Temp;
+use POSIX;
my $mail_to;
my $subject_prefix = "GIT";
$ref =~ s{^refs/heads/}{} or exit 0;
$old ne $new or exit 0;
+my $repo = POSIX::getcwd();
+$repo =~ s{.*/}{};
+
my $subj = '[' . $subject_prefix . ($ref eq 'master' ? '' : "/$ref") . ']';
-my $tmpdir = File::Temp->newdir() or die;
-my $outname = "$tmpdir/0";
-my $out = IO::File->new($outname, '>') or die;
+my $out = File::Temp->new() or die;
+my $outname = $out->filename;
$out->autoflush(1);
close STDOUT;
open STDOUT, '>&', $out or die;
my $pos_after_header = output_size();
# Show individual commits with diffs and stats
- system 'git', 'log', @rev_list_options, '--reverse', @diff_options, '--patch', '--stat', "$old..$new";
+ system 'git', 'log', @rev_list_options, '--reverse', @diff_options, '-p', '--stat', "$old..$new";
# If the file is too long, truncate it and print just a summary
if (defined($max_diff_size) && output_size() > $max_diff_size) {
system 'mutt',
'-F/dev/null',
'-x',
- '-e',
- 'set charset="utf-8"; set send_charset="us-ascii:iso-8859-2:utf-8"',
+ '-e', 'set charset="utf-8"',
+ '-e', 'set send_charset="us-ascii:iso-8859-2:utf-8"',
+ '-e', "my_hdr X-Git-Repo: $repo",
+ '-e', "my_hdr X-Git-Branch: $ref",
+ '-e', "my_hdr X-Git-Old-SHA: $old",
+ '-e', "my_hdr X-Git-New-SHA: $new",
'-s', $subj,
$mail_to;
} else {