Skip to content

Commit cbb7eb7

Browse files
committed
Perl: Support piping commands on MSWin32
Replace the legacy TIEHANDLE used to fake out a pipe and replace it with real pipes. As modern Perl seems to handle these simple pipes well, the need for a special-case object has evaporated. As a consequence of this change, input pipes are now supported. Closes: #1603 Signed-off-by: Chris Lindee <[email protected]>
1 parent 7040f0b commit cbb7eb7

File tree

2 files changed

+6
-46
lines changed

2 files changed

+6
-46
lines changed

perl/Git.pm

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,15 +1607,11 @@ sub _command_common_pipe {
16071607
# ActiveState Perl
16081608
#defined $opts{STDERR} and
16091609
# warn 'ignoring STDERR option - running w/ ActiveState';
1610-
$direction eq '-|' or
1611-
die 'input pipe for ActiveState not implemented';
1612-
# the strange construction with *ACPIPE is just to
1613-
# explain the tie below that we want to bind to
1614-
# a handle class, not scalar. It is not known if
1615-
# it is something specific to ActiveState Perl or
1616-
# just a Perl quirk.
1617-
tie (*ACPIPE, 'Git::activestate_pipe', $cmd, @args);
1618-
$fh = *ACPIPE;
1610+
my $cmdline = make_windows_commandline('git', $cmd, @args);
1611+
my $pid = open($fh, $direction, $cmdline);
1612+
if (not defined $pid) {
1613+
throw Error::Simple("open failed: $!");
1614+
}
16191615

16201616
} else {
16211617
my $pid = open($fh, $direction);
@@ -1686,42 +1682,6 @@ sub DESTROY {
16861682
}
16871683

16881684

1689-
# Pipe implementation for ActiveState Perl.
1690-
1691-
package Git::activestate_pipe;
1692-
1693-
sub TIEHANDLE {
1694-
my ($class, @params) = @_;
1695-
my $cmdline = make_windows_commandline('git', @params);
1696-
my @data = qx{$cmdline};
1697-
bless { i => 0, data => \@data }, $class;
1698-
}
1699-
1700-
sub READLINE {
1701-
my $self = shift;
1702-
if ($self->{i} >= scalar @{$self->{data}}) {
1703-
return undef;
1704-
}
1705-
my $i = $self->{i};
1706-
if (wantarray) {
1707-
$self->{i} = $#{$self->{'data'}} + 1;
1708-
return splice(@{$self->{'data'}}, $i);
1709-
}
1710-
$self->{i} = $i + 1;
1711-
return $self->{'data'}->[ $i ];
1712-
}
1713-
1714-
sub CLOSE {
1715-
my $self = shift;
1716-
delete $self->{data};
1717-
delete $self->{i};
1718-
}
1719-
1720-
sub EOF {
1721-
my $self = shift;
1722-
return ($self->{i} >= scalar @{$self->{data}});
1723-
}
1724-
17251685
sub make_windows_commandline {
17261686
my $cmdline = join ' ', unescape_windows_commandline_args(@_);
17271687

t/t9701/test.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BEGIN
2828
require_ok('Git');
2929

3030
foreach (@tests) {
31-
my $cmdline = Git::activestate_pipe::make_windows_commandline($^X, '-e', 'print $ARGV[0]', $_);
31+
my $cmdline = Git::make_windows_commandline($^X, '-e', 'print $ARGV[0]', $_);
3232
is qx{$cmdline}, $_, $cmdline;
3333
}
3434

0 commit comments

Comments
 (0)