Merge branch 'jc/perl' into next

* jc/perl:
  cvsimport: avoid open "-|" list form for Perl 5.6
  svnimport: avoid open "-|" list form for Perl 5.6
  send-email: avoid open "-|" list form for Perl 5.6
  rerere: avoid open "-|" list form for Perl 5.6
  fmt-merge-msg: avoid open "-|" list form for Perl 5.6
This commit is contained in:
Junio C Hamano 2006-02-20 14:25:50 -08:00
commit 98968450b2
5 changed files with 64 additions and 31 deletions

View File

@ -846,8 +846,12 @@ while(<CVS>) {
print "Drop $fn\n" if $opt_v; print "Drop $fn\n" if $opt_v;
} else { } else {
print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v; print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v;
open my $F, '-|', "git-hash-object -w $tmpname" my $pid = open(my $F, '-|');
die $! unless defined $pid;
if (!$pid) {
exec("git-hash-object", "-w", $tmpname)
or die "Cannot create object: $!\n"; or die "Cannot create object: $!\n";
}
my $sha = <$F>; my $sha = <$F>;
chomp $sha; chomp $sha;
close $F; close $F;

View File

@ -28,11 +28,12 @@ sub andjoin {
} }
sub repoconfig { sub repoconfig {
my $fh;
my $val; my $val;
eval { eval {
open $fh, '-|', 'git-repo-config', '--get', 'merge.summary' my $pid = open(my $fh, '-|');
or die "$!"; if (!$pid) {
exec('git-repo-config', '--get', 'merge.summary');
}
($val) = <$fh>; ($val) = <$fh>;
close $fh; close $fh;
}; };
@ -41,25 +42,32 @@ sub repoconfig {
sub current_branch { sub current_branch {
my $fh; my $fh;
open $fh, '-|', 'git-symbolic-ref', 'HEAD' or die "$!"; my $pid = open($fh, '-|');
die "$!" unless defined $pid;
if (!$pid) {
exec('git-symbolic-ref', 'HEAD') or die "$!";
}
my ($bra) = <$fh>; my ($bra) = <$fh>;
chomp($bra); chomp($bra);
close $fh or die "$!";
$bra =~ s|^refs/heads/||; $bra =~ s|^refs/heads/||;
if ($bra ne 'master') { if ($bra ne 'master') {
$bra = " into $bra"; $bra = " into $bra";
} else { } else {
$bra = ""; $bra = "";
} }
return $bra; return $bra;
} }
sub shortlog { sub shortlog {
my ($tip, $limit) = @_; my ($tip, $limit) = @_;
my ($fh, @result); my ($fh, @result);
open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order', my $pid = open($fh, '-|');
'--pretty=oneline', $tip, '^HEAD') die "$!" unless defined $pid;
or die "$!"; if (!$pid) {
exec('git-log', "--max-count=$limit", '--topo-order',
'--pretty=oneline', $tip, '^HEAD') or die "$!";
}
while (<$fh>) { while (<$fh>) {
s/^[0-9a-f]{40}\s+//; s/^[0-9a-f]{40}\s+//;
push @result, $_; push @result, $_;

View File

@ -131,7 +131,11 @@ sub record_preimage {
sub find_conflict { sub find_conflict {
my $in; my $in;
local $/ = "\0"; local $/ = "\0";
open $in, '-|', qw(git ls-files -z -u) or die "$!: ls-files"; my $pid = open($in, '-|');
die "$!" unless defined $pid;
if (!$pid) {
exec(qw(git ls-files -z -u)) or die "$!: ls-files";
}
my %path = (); my %path = ();
my @path = (); my @path = ();
while (<$in>) { while (<$in>) {

View File

@ -59,24 +59,29 @@ my $rc = GetOptions("from=s" => \$from,
# Now, let's fill any that aren't set in with defaults: # Now, let's fill any that aren't set in with defaults:
open(GITVAR,"-|","git-var","-l") sub gitvar {
or die "Failed to open pipe from git-var: $!"; my ($var) = @_;
my $fh;
my ($author,$committer); my $pid = open($fh, '-|');
while(<GITVAR>) { die "$!" unless defined $pid;
chomp; if (!$pid) {
my ($var,$data) = split /=/,$_,2; exec('git-var', $var) or die "$!";
my @fields = split /\s+/, $data; }
my ($val) = <$fh>;
my $ident = join(" ", @fields[0...(@fields-3)]); close $fh or die "$!";
chomp($val);
if ($var eq 'GIT_AUTHOR_IDENT') { return $val;
$author = $ident;
} elsif ($var eq 'GIT_COMMITTER_IDENT') {
$committer = $ident;
}
} }
close(GITVAR);
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 $prompting = 0; my $prompting = 0;
if (!defined $from) { if (!defined $from) {

View File

@ -10,7 +10,6 @@
# The head revision is on branch "origin" by default. # The head revision is on branch "origin" by default.
# You can change that with the '-o' option. # You can change that with the '-o' option.
require 5.008; # for shell-safe open("-|",LIST)
use strict; use strict;
use warnings; use warnings;
use Getopt::Std; use Getopt::Std;
@ -322,8 +321,12 @@ sub get_file($$$) {
return undef unless defined $name; return undef unless defined $name;
} }
open my $F, '-|', "git-hash-object", "-w", $name my $pid = open(my $F, '-|');
die $! unless defined $pid;
if (!$pid) {
exec("git-hash-object", "-w", $name)
or die "Cannot create object: $!\n"; or die "Cannot create object: $!\n";
}
my $sha = <$F>; my $sha = <$F>;
chomp $sha; chomp $sha;
close $F; close $F;
@ -398,7 +401,12 @@ sub copy_path($$$$$$$$) {
$srcpath =~ s#/*$#/#; $srcpath =~ s#/*$#/#;
} }
open my $f,"-|","git-ls-tree","-r","-z",$gitrev,$srcpath; my $pid = open my $f,'-|';
die $! unless defined $pid;
if (!$pid) {
exec("git-ls-tree","-r","-z",$gitrev,$srcpath)
or die $!;
}
local $/ = "\0"; local $/ = "\0";
while(<$f>) { while(<$f>) {
chomp; chomp;
@ -554,7 +562,11 @@ sub commit {
@o1 = @old; @o1 = @old;
@old = (); @old = ();
} }
open my $F, "-|", "git-ls-files", "-z", @o1 or die $!; my $pid = open my $F, "-|";
die "$!" unless defined $pid;
if (!$pid) {
exec("git-ls-files", "-z", @o1) or die $!;
}
@o1 = (); @o1 = ();
local $/ = "\0"; local $/ = "\0";
while(<$F>) { while(<$F>) {