git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Riesen" <raa.lkml@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH] Hack git-add--interactive to make it work with ActiveState Perl
Date: Wed, 1 Aug 2007 15:09:14 +0200	[thread overview]
Message-ID: <81b0412b0708010609h3346704bg4f708100bb5d6b93@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

It wont work for arguments with special characters (like ", : or *).
It is generally not possible on Windows, so I didn't even try.
---
 git-add--interactive.perl |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

[-- Attachment #2: 0001-Hack-git-add-interactive-to-make-it-work-with-ActiveS.txt --]
[-- Type: text/plain, Size: 1824 bytes --]

From 0206b165dab71b0dc6396f88cfb8f70f67277ddf Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Wed, 1 Aug 2007 14:57:43 +0200
Subject: [PATCH] Hack git-add--interactive to make it work with ActiveState Perl

It wont work for arguments with special characters (like ", : or *).
It is generally not possible on Windows, so I didn't even try.
---
 git-add--interactive.perl |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index dc30380..7921cde 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -3,9 +3,16 @@
 use strict;
 
 sub run_cmd_pipe {
-	my $fh = undef;
-	open($fh, '-|', @_) or die;
-	return <$fh>;
+	if ($^O eq 'MSWin32') {
+		my @invalid = grep {m/[":*]/} @_;
+		die "$^O does not support: @invalid\n" if @invalid;
+		my @args = map { m/ /o ? "\"$_\"": $_ } @_;
+		return qx{@args};
+	} else {
+		my $fh = undef;
+		open($fh, '-|', @_) or die;
+		return <$fh>;
+	}
 }
 
 my ($GIT_DIR) = run_cmd_pipe(qw(git rev-parse --git-dir));
@@ -17,7 +24,7 @@ chomp($GIT_DIR);
 
 sub refresh {
 	my $fh;
-	open $fh, '-|', qw(git update-index --refresh)
+	open $fh, 'git update-index --refresh |'
 	    or die;
 	while (<$fh>) {
 		;# ignore 'needs update'
@@ -296,7 +303,7 @@ sub revert_cmd {
 		my @lines = run_cmd_pipe(qw(git ls-tree HEAD --),
 					 map { $_->{VALUE} } @update);
 		my $fh;
-		open $fh, '|-', qw(git update-index --index-info)
+		open $fh, '| git update-index --index-info'
 		    or die;
 		for (@lines) {
 			print $fh $_;
@@ -725,7 +732,7 @@ sub patch_update_cmd {
 	if (@result) {
 		my $fh;
 
-		open $fh, '|-', qw(git apply --cached);
+		open $fh, '| git apply --cached';
 		for (@{$head->{TEXT}}, @result) {
 			print $fh $_;
 		}
-- 
1.5.3.rc3.145.g4d9cdb


                 reply	other threads:[~2007-08-01 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=81b0412b0708010609h3346704bg4f708100bb5d6b93@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).