aboutsummaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-30 23:38:24 -0700
committerJunio C Hamano <junkio@cox.net>2006-09-30 23:38:24 -0700
commit69de8cc8527dc45a7aef76e8f1ace45b509b3712 (patch)
treea1eedc952588f20afe95e8488e2f4664b13dc597 /git-send-email.perl
parentdd0c367e5e1358539bdd11c3a474bb6792504d30 (diff)
parentf7661ce0b8ee068e53d57249625199dda2829e30 (diff)
downloadgit-69de8cc8527dc45a7aef76e8f1ace45b509b3712.tar.gz
git-69de8cc8527dc45a7aef76e8f1ace45b509b3712.tar.xz
Merge branch 'jc/gitpm'
* jc/gitpm: (52 commits) Remove -fPIC which was only needed for Git.xs Git.pm: Kill Git.xs for now Revert "Make it possible to set up libgit directly (instead of from the environment)" Revert "Git.pm: Introduce fast get_object() method" Revert "Convert git-annotate to use Git.pm" Fix compilation with Sun CC pass DESTDIR to the generated perl/Makefile Eliminate Scalar::Util usage from private-Error.pm Convert git-annotate to use Git.pm Git.pm: Introduce fast get_object() method Make it possible to set up libgit directly (instead of from the environment) Work around sed and make interactions on the backslash at the end of line. Git.pm: Introduce ident() and ident_person() methods Convert git-send-email to use Git.pm Git.pm: Add config() method Use $GITPERLLIB instead of $RUNNING_GIT_TESTS and centralize @INC munging INSTALL: a tip for running after building but without installing. Perly Git: make sure we do test the freshly built one. Git.pm: Don't #define around die Git.xs: older perl do not know const char * ...
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl38
1 files changed, 8 insertions, 30 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 746c52507..4a2031084 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -21,6 +21,7 @@ use warnings;
use Term::ReadLine;
use Getopt::Long;
use Data::Dumper;
+use Git;
package FakeTerm;
sub new {
@@ -92,6 +93,7 @@ my $smtp_server;
# Example reply to:
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
+my $repo = Git->repository();
my $term = eval {
new Term::ReadLine 'git-send-email';
};
@@ -132,33 +134,12 @@ foreach my $entry (@bcclist) {
# 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 {
- my ($name) = @_;
- my $val = gitvar($name);
- my @field = split(/\s+/, $val);
- return join(' ', @field[0...(@field-3)]);
-}
-
-my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');
-my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
+my ($author) = $repo->ident_person('author');
+my ($committer) = $repo->ident_person('committer');
my %aliases;
-chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);
-chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);
+my @alias_files = $repo->config('sendemail.aliasesfile');
+my $aliasfiletype = $repo->config('sendemail.aliasfiletype');
my %parse_alias = (
# multiline formats can be supported in the future
mutt => sub { my $fh = shift; while (<$fh>) {
@@ -183,7 +164,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) {
open my $fh, '<', $file or die "opening $file: $!\n";
$parse_alias{$aliasfiletype}->($fh);
@@ -425,10 +406,7 @@ sub send_message
my $date = format_2822_time($time++);
my $gitversion = '@@GIT_VERSION@@';
if ($gitversion =~ m/..GIT_VERSION../) {
- $gitversion = `git --version`;
- chomp $gitversion;
- # keep only what's after the last space
- $gitversion =~ s/^.* //;
+ $gitversion = Git::version();
}
my $header = "From: $from