From 31b228c7c741065246b6e65dfadbbce28ff5d539 Mon Sep 17 00:00:00 2001 From: albfan Date: Wed, 9 Jul 2014 11:30:33 +0200 Subject: [PATCH] fix for long command line on git-add-interactive See https://github.com/msysgit/git/issues/182 for more details This implementation is not checked. It was created from @PhilipDavis proposal https://gist.github.com/PhilipDavis/a7e8843dad39493a698c --- git-add--interactive.perl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 32c2f9cf88201b..86b1e344cd13a9 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -175,8 +175,32 @@ sub run_cmd_pipe { my @args = map { m/ /o ? "\"$_\"": $_ } @_; return qx{@args}; } else { + + # 2014-08-07 - Phil - Write filename args to a temporary file + my @myArgs = @_; + my $cmd = "@myArgs"; + my $path = "$ENV{APPDATA}"; + $path =~ s/\\/\//g; + use File::Temp qw(tempfile); + my ($fhargs, $filename) = tempfile("$path/git-args-XXXXXX", UNLINK => 1); + if (grep $_ eq "--", @myArgs) { + $cmd = ""; + while ($myArgs[0] ne '--') { + $cmd = $cmd . shift(@myArgs) . " "; + } + $cmd = $cmd . "-- "; + shift(@myArgs); + + foreach (@myArgs) { + print $fhargs "$_ "; + } + $fhargs->flush; + $cmd = $cmd . "< $filename"; + } + my $fh = undef; - open($fh, '-|', @_) or die; + open($fh, '-|', $cmd) or die; + close $fhargs; return <$fh>; } }