Commits

Anonymous committed 21e9757

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.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Comments (0)

Files changed (1)

git-add--interactive.perl

 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));
 
 sub refresh {
 	my $fh;
-	open $fh, '-|', qw(git update-index --refresh)
+	open $fh, 'git update-index --refresh |'
 	    or die;
 	while (<$fh>) {
 		;# ignore 'needs update'
 		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 $_;
 	if (@result) {
 		my $fh;
 
-		open $fh, '|-', qw(git apply --cached);
+		open $fh, '| git apply --cached';
 		for (@{$head->{TEXT}}, @result) {
 			print $fh $_;
 		}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.