提交 21e9757e 编写于 作者: A Alex Riesen 提交者: Junio C Hamano

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: NJunio C Hamano <gitster@pobox.com>
上级 96ffe892
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
use strict; use strict;
sub run_cmd_pipe { sub run_cmd_pipe {
my $fh = undef; if ($^O eq 'MSWin32') {
open($fh, '-|', @_) or die; my @invalid = grep {m/[":*]/} @_;
return <$fh>; 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)); my ($GIT_DIR) = run_cmd_pipe(qw(git rev-parse --git-dir));
...@@ -17,7 +24,7 @@ sub run_cmd_pipe { ...@@ -17,7 +24,7 @@ sub run_cmd_pipe {
sub refresh { sub refresh {
my $fh; my $fh;
open $fh, '-|', qw(git update-index --refresh) open $fh, 'git update-index --refresh |'
or die; or die;
while (<$fh>) { while (<$fh>) {
;# ignore 'needs update' ;# ignore 'needs update'
...@@ -296,7 +303,7 @@ sub revert_cmd { ...@@ -296,7 +303,7 @@ sub revert_cmd {
my @lines = run_cmd_pipe(qw(git ls-tree HEAD --), my @lines = run_cmd_pipe(qw(git ls-tree HEAD --),
map { $_->{VALUE} } @update); map { $_->{VALUE} } @update);
my $fh; my $fh;
open $fh, '|-', qw(git update-index --index-info) open $fh, '| git update-index --index-info'
or die; or die;
for (@lines) { for (@lines) {
print $fh $_; print $fh $_;
...@@ -725,7 +732,7 @@ sub patch_update_cmd { ...@@ -725,7 +732,7 @@ sub patch_update_cmd {
if (@result) { if (@result) {
my $fh; my $fh;
open $fh, '|-', qw(git apply --cached); open $fh, '| git apply --cached';
for (@{$head->{TEXT}}, @result) { for (@{$head->{TEXT}}, @result) {
print $fh $_; print $fh $_;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册