Convert git-send-email to use Git.pm
Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
dc2613de86
commit
3cb8caf729
|
@ -21,6 +21,7 @@ use warnings;
|
||||||
use Term::ReadLine;
|
use Term::ReadLine;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
use Git;
|
||||||
|
|
||||||
# most mail servers generate the Date: header, but not all...
|
# most mail servers generate the Date: header, but not all...
|
||||||
$ENV{LC_ALL} = 'C';
|
$ENV{LC_ALL} = 'C';
|
||||||
|
@ -46,6 +47,8 @@ my $smtp_server;
|
||||||
# Example reply to:
|
# Example reply to:
|
||||||
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
|
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
|
||||||
|
|
||||||
|
my $repo = Git->repository();
|
||||||
|
|
||||||
my $term = new Term::ReadLine 'git-send-email';
|
my $term = new Term::ReadLine 'git-send-email';
|
||||||
|
|
||||||
# Begin by accumulating all the variables (defined above), that we will end up
|
# Begin by accumulating all the variables (defined above), that we will end up
|
||||||
|
@ -81,23 +84,9 @@ foreach my $entry (@bcclist) {
|
||||||
|
|
||||||
# Now, let's fill any that aren't set in with defaults:
|
# Now, let's fill any that aren't set in with defaults:
|
||||||
|
|
||||||
sub gitvar {
|
|
||||||
my ($var) = @_;
|
|
||||||
my $fh;
|
|
||||||
my $pid = open($fh, '-|');
|
|
||||||
die "$!" unless defined $pid;
|
|
||||||
if (!$pid) {
|
|
||||||
exec('git-var', $var) or die "$!";
|
|
||||||
}
|
|
||||||
my ($val) = <$fh>;
|
|
||||||
close $fh or die "$!";
|
|
||||||
chomp($val);
|
|
||||||
return $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub gitvar_ident {
|
sub gitvar_ident {
|
||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
my $val = gitvar($name);
|
my $val = $repo->command('var', $name);
|
||||||
my @field = split(/\s+/, $val);
|
my @field = split(/\s+/, $val);
|
||||||
return join(' ', @field[0...(@field-3)]);
|
return join(' ', @field[0...(@field-3)]);
|
||||||
}
|
}
|
||||||
|
@ -106,8 +95,8 @@ my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');
|
||||||
my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
|
my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
|
||||||
|
|
||||||
my %aliases;
|
my %aliases;
|
||||||
chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);
|
my @alias_files = $repo->config('sendemail.aliasesfile');
|
||||||
chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);
|
my $aliasfiletype = $repo->config('sendemail.aliasfiletype');
|
||||||
my %parse_alias = (
|
my %parse_alias = (
|
||||||
# multiline formats can be supported in the future
|
# multiline formats can be supported in the future
|
||||||
mutt => sub { my $fh = shift; while (<$fh>) {
|
mutt => sub { my $fh = shift; while (<$fh>) {
|
||||||
|
@ -132,7 +121,7 @@ my %parse_alias = (
|
||||||
}}}
|
}}}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (@alias_files && defined $parse_alias{$aliasfiletype}) {
|
if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
|
||||||
foreach my $file (@alias_files) {
|
foreach my $file (@alias_files) {
|
||||||
open my $fh, '<', $file or die "opening $file: $!\n";
|
open my $fh, '<', $file or die "opening $file: $!\n";
|
||||||
$parse_alias{$aliasfiletype}->($fh);
|
$parse_alias{$aliasfiletype}->($fh);
|
||||||
|
@ -374,10 +363,7 @@ sub send_message
|
||||||
my $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));
|
my $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));
|
||||||
my $gitversion = '@@GIT_VERSION@@';
|
my $gitversion = '@@GIT_VERSION@@';
|
||||||
if ($gitversion =~ m/..GIT_VERSION../) {
|
if ($gitversion =~ m/..GIT_VERSION../) {
|
||||||
$gitversion = `git --version`;
|
$gitversion = Git::version();
|
||||||
chomp $gitversion;
|
|
||||||
# keep only what's after the last space
|
|
||||||
$gitversion =~ s/^.* //;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $header = "From: $from
|
my $header = "From: $from
|
||||||
|
|
Loading…
Reference in New Issue