Re: [BUG] regarding `git add -p` and files containing wildcard characters
- From
Jeff King <peff@peff.net>
- Date
- Dec 9, 2016, 05:37 UTC
- Message-ID
- <20161209053751.dpq3brm6pih3rc3n@sigill.intra.peff.net>
- In-Reply-To
- <c9876671-6252-5dfa-18df-a6719dc6834c@gmail.com>
On Fri, Dec 09, 2016 at 04:46:49AM +0300, unixway.drive@gmail.com wrote:
> The problem is that `git-diff-files` does some globbing on the 'path' > arguments on its own and has no option to disable that (and > `git-add--interactive`'s `run_cmd_pipe` already handles all other sorts of > unsafe characters like spaces and backticks well).
I think the option you're looking for is:
git --literal-pathspecs diff-files ... -- 'Random *'
I don't know if there are other commands run by add--interactive that would want the same treatment. It might actually make sense to set GIT_LITERAL_PATHSPECS=1 in the environment right after it expands the list via ls-files.
Show 15 quoted lines
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index ee3d812..358d877 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -2,3 +2,3 @@
>
> -use 5.008;
> +use 5.014;
> use strict;
> @@ -761,3 +761,5 @@ sub parse_diff {
> }
> - my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path);
> + my @diff = run_cmd_pipe("git", @diff_cmd, "--", (
> + $path =~ s#[\[*?]#\\$&#gr
> + ));This callsite covers "-p". It looks like list_modified() probably needs similar treatment. Maybe others; I didn't look exhaustively.
-Peff