nd/magic-pathspec exposes breakage in git-add--interactive on Windows
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Aug 29, 2013, 06:54 UTC
- Message-ID
- <521EF02A.2020300@viscovery.net>
With nd/magic-pathspec I get the following failure on Windows in t2016-checkout-patch.sh:
expecting success:
set_state dir/foo work head &&
# the third n is to get out in case it mistakenly does not apply
(echo y; echo n; echo n) | (cd dir && git checkout -p foo) &&
verify_saved_state bar &&
verify_state dir/foo head head==== xx. ==== 1d. ==== 10e. msys does not support: :(prefix:4)dir/foo not ok 13 - path limiting works: foo inside dir
The error message 'msys does not support...' originates from this function in git-add--interactive.perl (which is invoked from checkout -p):
sub run_cmd_pipe {
if ($^O eq 'MSWin32' || $^O eq 'msys') {
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>;
}
}It looks like on Windows we disallow arguments that contain double-quote, colon, or asterisk, and otherwise wrap arguments in double-quotes if they contain space. Then pass them through qx{}, which I can only guess what it does.
This code was introduced in 21e9757e (Hack git-add--interactive to make it work with ActiveState Perl, 2007-08-01). The commit message has the general statement "It wont work for arguments with special characters (like ", : or *)), which I do not know how to interpret: Does ActiveState Perl not work with special charactoers, or Windows? Because the latter is definitely not true.
Can we be more permissive in the 'my @invalid' check without breaking ActiveState Perl?
BTW, there is a similar failure in t7105-reset-patch.sh, which invokes 'git reset -p', but I haven't investigate further.
-- Hannes