X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-add--interactive.perl;h=7921cde8cbd3b58f1d7222e9828bf85e10f363e3;hb=e4cd6c7a20bfc776086817671d58e09060a8079a;hp=0057f865886753afb9493a2e82b11fe14aa91529;hpb=1fcdd62adf81a172f45c7c6a58177212d500b9d9;p=git.git diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 0057f8658..7921cde8c 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1,12 +1,18 @@ #!/usr/bin/perl -w - 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)); @@ -18,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' @@ -282,7 +288,7 @@ sub update_cmd { HEADER => $status_head, }, @mods); if (@update) { - system(qw(git update-index --add --), + system(qw(git update-index --add --remove --), map { $_->{VALUE} } @update); say_n_paths('updated', @update); } @@ -297,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 $_; @@ -726,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 $_; }