aboutsummaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-02-20 14:23:51 -0800
committerJunio C Hamano <junkio@cox.net>2006-02-20 14:23:51 -0800
commite415907d6c746616f399cf2a4679372dd0cbce83 (patch)
tree7f1d80dfeda972f9445d2eeb4ffe34eedd5b38ab /git-send-email.perl
parentfedd273b758e6aa844555e4e50ebfce59255e015 (diff)
downloadgit-e415907d6c746616f399cf2a4679372dd0cbce83.tar.gz
git-e415907d6c746616f399cf2a4679372dd0cbce83.tar.xz
send-email: avoid open "-|" list form for Perl 5.6
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl37
1 files changed, 21 insertions, 16 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 13b85dddd..b0d095b4e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -59,24 +59,29 @@ my $rc = GetOptions("from=s" => \$from,
# Now, let's fill any that aren't set in with defaults:
-open(GITVAR,"-|","git-var","-l")
- or die "Failed to open pipe from git-var: $!";
-
-my ($author,$committer);
-while(<GITVAR>) {
- chomp;
- my ($var,$data) = split /=/,$_,2;
- my @fields = split /\s+/, $data;
-
- my $ident = join(" ", @fields[0...(@fields-3)]);
+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;
+}
- if ($var eq 'GIT_AUTHOR_IDENT') {
- $author = $ident;
- } elsif ($var eq 'GIT_COMMITTER_IDENT') {
- $committer = $ident;
- }
+sub gitvar_ident {
+ my ($name) = @_;
+ my $val = gitvar($name);
+ my @field = split(/\s+/, $val);
+ return join(' ', @field[0...(@field-3)]);
}
-close(GITVAR);
+
+my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');
+my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
my $prompting = 0;
if (!defined $from) {