From 2a86ec46da99e4cd5e6e394d378ba119d8f5069d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Feb 2006 14:02:25 -0800 Subject: [PATCH 1/5] fmt-merge-msg: avoid open "-|" list form for Perl 5.6 Signed-off-by: Junio C Hamano --- git-fmt-merge-msg.perl | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) 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, $_; From fedd273b758e6aa844555e4e50ebfce59255e015 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Feb 2006 14:02:47 -0800 Subject: [PATCH 2/5] rerere: avoid open "-|" list form for Perl 5.6 Signed-off-by: Junio C Hamano --- git-rerere.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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>) { From e415907d6c746616f399cf2a4679372dd0cbce83 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Feb 2006 14:23:51 -0800 Subject: [PATCH 3/5] send-email: avoid open "-|" list form for Perl 5.6 Signed-off-by: Junio C Hamano --- git-send-email.perl | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) 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)]); +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) { From 7ae0dc015dc38ce937bb2c044ff8b4875678e8af Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Feb 2006 14:14:15 -0800 Subject: [PATCH 4/5] svnimport: avoid open "-|" list form for Perl 5.6 Signed-off-by: Junio C Hamano --- git-svnimport.perl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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>) { From dd27478f092295069b148a4cfcf92fea9a4aab03 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Feb 2006 14:17:28 -0800 Subject: [PATCH 5/5] cvsimport: avoid open "-|" list form for Perl 5.6 Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;