Web lists-archives.com

Re: [PATCH 2/2] built-in stash: handle :(glob) pathspecs again




"Johannes Schindelin via GitGitGadget" <gitgitgadget@xxxxxxxxx>
writes:

> From: Johannes Schindelin <johannes.schindelin@xxxxxx>
>
> When passing a list of pathspecs to, say, `git add`, we need to be
> careful to use the original form, not the parsed form of the pathspecs.
>
> This makes a difference e.g. when calling
>
> 	git stash -- ':(glob)**/*.txt'
>
> where the original form includes the `:(glob)` prefix while the parsed
> form does not.
>
> However, in the built-in `git stash`, we passed the parsed (i.e.
> incorrect) form, and `git add` would fail with the error message:
>
> 	fatal: pathspec '**/*.txt' did not match any files
>
> at the stage where `git stash` drops the changes from the worktree, even
> if `refs/stash` has been actually updated successfully.
>
> This fixes https://github.com/git-for-windows/git/issues/2037
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
> ---
>  builtin/stash.c                    | 5 +++--
>  t/t3905-stash-include-untracked.sh | 6 ++++++
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/stash.c b/builtin/stash.c
> index 1bfa24030c..2f29d037c8 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -830,7 +830,7 @@ static void add_pathspecs(struct argv_array *args,
>  	int i;
>  
>  	for (i = 0; i < ps.nr; i++)
> -		argv_array_push(args, ps.items[i].match);
> +		argv_array_push(args, ps.items[i].original);
>  }

Yup.  I think Thomas and Peff were also looking at the vicinity of
this code wrt the pass-by-value-ness of ps parameter.  Their fix
need to also come on top of this (or combined together).