From: Ryan Anderson <ryan@michonline.com>
To: junkio@cox.net
Cc: merlyn@stonehenge.com, git@vger.kernel.org,
Ryan Anderson <ryan@michonline.com>
Subject: [PATCH] annotate: Use qx{} for pipes on activestate.
Date: Sun, 26 Feb 2006 16:09:12 -0500 [thread overview]
Message-ID: <11409881522219-git-send-email-ryan@michonline.com> (raw)
In-Reply-To: <1140922925166-git-send-email-ryan@michonline.com>
Note: This needs someone to tell me what the value of $^O is on ActiveState.
Signed-off-by: Ryan Anderson <ryan@michonline.com>
---
As always, available in
http://h4x0r5.com/~ryan/git/ryan.git/ annotate-upstream
Randal, does this look basically the right approach here?
(I would like to make that glob I use not a global, but I can't
seem to figure out how at the moment.)
git-annotate.perl | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
a927bb08b9b319cc3832fcf354a75e3760af593c
diff --git a/git-annotate.perl b/git-annotate.perl
index ee8ff15..f9c2c6c 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}});
+}
--
1.2.3.g9ca3
prev parent reply other threads:[~2006-02-26 21:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-26 1:48 [PATCH] annotate: Handle dirty state and arbitrary revisions Ryan Anderson
2006-02-26 3:02 ` [PATCH] annotate: Convert all -| calls to use a helper open_pipe() Ryan Anderson
2006-02-26 21:09 ` Ryan Anderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11409881522219-git-send-email-ryan@michonline.com \
--to=ryan@michonline.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=merlyn@stonehenge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.