@@ -3406,6 +3406,22 @@ sub refHashEqual
3406
3406
return $out ;
3407
3407
}
3408
3408
3409
+ # an alternative to `command` that allows input to be passed as an array
3410
+ # to work around shell problems with weird characters in arguments
3411
+
3412
+ sub safe_pipe_capture {
3413
+
3414
+ my @output ;
3415
+
3416
+ if (my $pid = open my $child , ' -|' ) {
3417
+ @output = (<$child >);
3418
+ close $child or die join (' ' ,@_ )." : $! $? " ;
3419
+ } else {
3420
+ exec (@_ ) or die " $! $? " ; # exec() can fail the executable can't be found
3421
+ }
3422
+ return wantarray ? @output : join (' ' ,@output );
3423
+ }
3424
+
3409
3425
3410
3426
package GITCVS::log ;
3411
3427
@@ -3882,7 +3898,7 @@ sub update
3882
3898
# several candidate merge bases. let's assume
3883
3899
# that the first one is the best one.
3884
3900
my $base = eval {
3885
- safe_pipe_capture(' git' , ' merge-base' ,
3901
+ :: safe_pipe_capture(' git' , ' merge-base' ,
3886
3902
$lastpicked , $parent );
3887
3903
};
3888
3904
# The two branches may not be related at all,
@@ -4749,7 +4765,7 @@ sub getMetaFromCommithash
4749
4765
return $retVal ;
4750
4766
}
4751
4767
4752
- my ($fileHash )= safe_pipe_capture(" git" ," rev-parse" ," $revCommit :$filename " );
4768
+ my ($fileHash ) = :: safe_pipe_capture(" git" ," rev-parse" ," $revCommit :$filename " );
4753
4769
chomp $fileHash ;
4754
4770
if (!($fileHash =~/ ^[0-9a-f]{40}$ / ))
4755
4771
{
@@ -4844,8 +4860,8 @@ sub lookupCommitRef
4844
4860
return $commitHash ;
4845
4861
}
4846
4862
4847
- $commitHash = safe_pipe_capture(" git" ," rev-parse" ," --verify" ," --quiet" ,
4848
- $self -> unescapeRefName($ref ));
4863
+ $commitHash = :: safe_pipe_capture(" git" ," rev-parse" ," --verify" ," --quiet" ,
4864
+ $self -> unescapeRefName($ref ));
4849
4865
$commitHash =~s /\s *$// ;
4850
4866
if (!($commitHash =~/ ^[0-9a-f]{40}$ / ))
4851
4867
{
@@ -4854,7 +4870,7 @@ sub lookupCommitRef
4854
4870
4855
4871
if ( defined ($commitHash ) )
4856
4872
{
4857
- my $type = safe_pipe_capture(" git" ," cat-file" ," -t" ,$commitHash );
4873
+ my $type = :: safe_pipe_capture(" git" ," cat-file" ," -t" ,$commitHash );
4858
4874
if ( ! ($type =~/ ^commit\s *$ / ) )
4859
4875
{
4860
4876
$commitHash =undef ;
@@ -4907,7 +4923,7 @@ sub commitmessage
4907
4923
return $message ;
4908
4924
}
4909
4925
4910
- my @lines = safe_pipe_capture(" git" , " cat-file" , " commit" , $commithash );
4926
+ my @lines = :: safe_pipe_capture(" git" , " cat-file" , " commit" , $commithash );
4911
4927
shift @lines while ( $lines [0] =~ / \S / );
4912
4928
$message = join (" " ,@lines );
4913
4929
$message .= " " if ( $message =~ / \n $ / );
@@ -5056,25 +5072,6 @@ sub in_array
5056
5072
return $retval ;
5057
5073
}
5058
5074
5059
- =head2 safe_pipe_capture
5060
-
5061
- an alternative to `command` that allows input to be passed as an array
5062
- to work around shell problems with weird characters in arguments
5063
-
5064
- =cut
5065
- sub safe_pipe_capture {
5066
-
5067
- my @output ;
5068
-
5069
- if (my $pid = open my $child , ' -|' ) {
5070
- @output = (<$child >);
5071
- close $child or die join (' ' ,@_ )." : $! $? " ;
5072
- } else {
5073
- exec (@_ ) or die " $! $? " ; # exec() can fail the executable can't be found
5074
- }
5075
- return wantarray ? @output : join (' ' ,@output );
5076
- }
5077
-
5078
5075
=head2 mangle_dirname
5079
5076
5080
5077
create a string from a directory name that is suitable to use as
0 commit comments