Skip to content

Commit

Permalink
annotate: Use qx{} for pipes on activestate.
Browse files Browse the repository at this point in the history
Note: This needs someone to tell me what the value of $^O is on ActiveState.

Signed-off-by: Ryan Anderson <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pugmajere authored and Junio C Hamano committed Feb 26, 2006
1 parent 6b3e21d commit f60d469
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion git-annotate.perl
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,20 @@ sub gitvar_name {
return join(' ', @field[0...(@field-4)]);
}


sub open_pipe {
if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') {
return open_pipe_activestate(@_);
} else {
return open_pipe_normal(@_);
}
}

sub open_pipe_activestate {
tie *fh, "Git::ActiveStatePipe", @_;
return *fh;
}

sub open_pipe_normal {
my (@execlist) = @_;

my $pid = open my $kid, "-|";
Expand All @@ -445,3 +457,32 @@ sub open_pipe {

return $kid;
}

package Git::ActiveStatePipe;
use strict;

sub TIEHANDLE {
my ($class, @params) = @_;
my $cmdline = join " ", @params;
my @data = qx{$cmdline};
bless { i => 0, data => \@data }, $class;
}

sub READLINE {
my $self = shift;
if ($self->{i} >= scalar @{$self->{data}}) {
return undef;
}
return $self->{'data'}->[ $self->{i}++ ];
}

sub CLOSE {
my $self = shift;
delete $self->{data};
delete $self->{i};
}

sub EOF {
my $self = shift;
return ($self->{i} >= scalar @{$self->{data}});
}

0 comments on commit f60d469

Please sign in to comment.