Skip to content

Commit

Permalink
Hack git-add--interactive to make it work with ActiveState Perl
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Aug 2, 2007
1 parent 96ffe89 commit 21e9757
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -17,7 +24,7 @@ sub run_cmd_pipe {

sub refresh {
my $fh;
open $fh, '-|', qw(git update-index --refresh)
open $fh, 'git update-index --refresh |'
or die;
while (<$fh>) {
;# ignore 'needs update'
Expand Down Expand Up @@ -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 $_;
Expand Down Expand Up @@ -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 $_;
}
Expand Down

0 comments on commit 21e9757

Please sign in to comment.