aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Anderson <ryan@michonline.com>2006-02-26 16:09:12 -0500
committerJunio C Hamano <junkio@cox.net>2006-02-26 14:45:22 -0800
commitf60d46911dd0c0526339b039ced8772773bd3dea (patch)
treef790613559fa5c219332cb252e8ca7a57230b2d6
parent6b3e21d6031e1e8df8b01cba5ab7374c4b721257 (diff)
downloadgit-f60d46911dd0c0526339b039ced8772773bd3dea.tar.gz
git-f60d46911dd0c0526339b039ced8772773bd3dea.tar.xz
annotate: Use qx{} for pipes on activestate.
Note: This needs someone to tell me what the value of $^O is on ActiveState. Signed-off-by: Ryan Anderson <ryan@michonline.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xgit-annotate.perl43
1 files changed, 42 insertions, 1 deletions
diff --git a/git-annotate.perl b/git-annotate.perl
index ee8ff1579..f9c2c6caf 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -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, "-|";
@@ -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}});
+}