@matheusbsbs / matheus-bagliano / commits / 21e9757e31
Fork 0

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>

Alex Riesen committed Aug 1, 2007 at 14:57 UTC 21e9757e31d136fad0c04f3ce9da11b8b128b4f2
1 file changed +13 -6
git-add--interactive.perl
+13 -6
@@ -3,9 +3,16 @@
3 use strict;
4
5 sub run_cmd_pipe {
6 - my $fh = undef;
7 - open($fh, '-|', @_) or die;
8 - return <$fh>;
6 + if ($^O eq 'MSWin32') {
7 + my @invalid = grep {m/[":*]/} @_;
8 + die "$^O does not support: @invalid\n" if @invalid;
9 + my @args = map { m/ /o ? "\"$_\"": $_ } @_;
10 + return qx{@args};
11 + } else {
12 + my $fh = undef;
13 + open($fh, '-|', @_) or die;
14 + return <$fh>;
15 + }
16 }
17
18 my ($GIT_DIR) = run_cmd_pipe(qw(git rev-parse --git-dir));
@@ -17,7 +24,7 @@ chomp($GIT_DIR);
24
25 sub refresh {
26 my $fh;
20 - open $fh, '-|', qw(git update-index --refresh)
27 + open $fh, 'git update-index --refresh |'
28 or die;
29 while (<$fh>) {
30 ;# ignore 'needs update'
@@ -296,7 +303,7 @@ sub revert_cmd {
303 my @lines = run_cmd_pipe(qw(git ls-tree HEAD --),
304 map { $_->{VALUE} } @update);
305 my $fh;
299 - open $fh, '|-', qw(git update-index --index-info)
306 + open $fh, '| git update-index --index-info'
307 or die;
308 for (@lines) {
309 print $fh $_;
@@ -725,7 +732,7 @@ sub patch_update_cmd {
732 if (@result) {
733 my $fh;
734
728 - open $fh, '|-', qw(git apply --cached);
735 + open $fh, '| git apply --cached';
736 for (@{$head->{TEXT}}, @result) {
737 print $fh $_;
738 }