diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 24f9834342..b46469ab32 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -846,8 +846,12 @@ while() { print "Drop $fn\n" if $opt_v; } else { 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"; + } my $sha = <$F>; chomp $sha; close $F; diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl index c34ddc5d5e..a77e94eb5a 100755 --- a/git-fmt-merge-msg.perl +++ b/git-fmt-merge-msg.perl @@ -28,11 +28,12 @@ sub andjoin { } sub repoconfig { - my $fh; my $val; eval { - open $fh, '-|', 'git-repo-config', '--get', 'merge.summary' - or die "$!"; + my $pid = open(my $fh, '-|'); + if (!$pid) { + exec('git-repo-config', '--get', 'merge.summary'); + } ($val) = <$fh>; close $fh; }; @@ -41,25 +42,32 @@ sub repoconfig { sub current_branch { 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>; chomp($bra); + close $fh or die "$!"; $bra =~ s|^refs/heads/||; if ($bra ne 'master') { $bra = " into $bra"; } else { $bra = ""; } - return $bra; } sub shortlog { my ($tip, $limit) = @_; my ($fh, @result); - open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order', - '--pretty=oneline', $tip, '^HEAD') - or die "$!"; + my $pid = open($fh, '-|'); + die "$!" unless defined $pid; + if (!$pid) { + exec('git-log', "--max-count=$limit", '--topo-order', + '--pretty=oneline', $tip, '^HEAD') or die "$!"; + } while (<$fh>) { s/^[0-9a-f]{40}\s+//; push @result, $_; diff --git a/git-rerere.perl b/git-rerere.perl index df119517fe..d3664ff491 100755 --- a/git-rerere.perl +++ b/git-rerere.perl @@ -131,7 +131,11 @@ sub record_preimage { sub find_conflict { my $in; 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 = (); while (<$in>) { diff --git a/git-send-email.perl b/git-send-email.perl index 13b85dddd1..b0d095b4e9 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() { - chomp; - my ($var,$data) = split /=/,$_,2; - my @fields = split /\s+/, $data; - - my $ident = join(" ", @fields[0...(@fields-3)]); - - if ($var eq 'GIT_AUTHOR_IDENT') { - $author = $ident; - } elsif ($var eq 'GIT_COMMITTER_IDENT') { - $committer = $ident; - } +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; } -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; if (!defined $from) { diff --git a/git-svnimport.perl b/git-svnimport.perl index c536d7026d..ee2940f480 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -10,7 +10,6 @@ # The head revision is on branch "origin" by default. # You can change that with the '-o' option. -require 5.008; # for shell-safe open("-|",LIST) use strict; use warnings; use Getopt::Std; @@ -322,8 +321,12 @@ sub get_file($$$) { 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"; + } my $sha = <$F>; chomp $sha; close $F; @@ -398,7 +401,12 @@ sub copy_path($$$$$$$$) { $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"; while(<$f>) { chomp; @@ -554,7 +562,11 @@ sub commit { @o1 = @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 = (); local $/ = "\0"; while(<$F>) {