Re: [PATCH] dir.c: literal match with wildcard in pathspec should still glob
- From
JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com>
- Date
- May 3, 2025, 06:24 UTC
- Message-ID
- <CA+rGoLfFCi-q52ABUr=0O=pu+qSikcomSk1akHWUkfAfSf=pZg@mail.gmail.com>
- In-Reply-To
- <20250503060736.587286-1-jayatheerthkulkarni2005@gmail.com>
On Sat, May 3, 2025 at 11:37 AM K Jayatheerth <jayatheerthkulkarni2005@gmail.com> wrote:
Show 32 quoted lines
> > With a path with wildcard characters, e.g. 'f*o', exists in the > working tree, "git add -- 'f*o'" stops after happily finding > that there is 'f*o' and adding it to the index, without > realizing there may be other paths, e.g. 'foooo', that may match > the given pathspec. > > This is because dir.c:do_match_pathspec() disables further > matches with pathspec when it finds an exact match. > > Reported-by: piotrsiupa <piotrsiupa@gmail.com> > Helped-by: Jeff King <peff@peff.net> > Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> > --- > dir.c | 3 +- > t/meson.build | 1 + > t/t6137-pathspec-wildcards-literal.sh | 429 ++++++++++++++++++++++++++ > 3 files changed, 432 insertions(+), 1 deletion(-) > create mode 100755 t/t6137-pathspec-wildcards-literal.sh > > diff --git a/dir.c b/dir.c > index 28b0e03feb..9405fee83a 100644 > --- a/dir.c > +++ b/dir.c > @@ -519,7 +519,8 @@ static int do_match_pathspec(struct index_state *istate, > ( exclude && !(ps->items[i].magic & PATHSPEC_EXCLUDE))) > continue; > > - if (seen && seen[i] == MATCHED_EXACTLY) > + if (seen && seen[i] == MATCHED_EXACTLY && > + ps->items[i].nowildcard_len == ps->items[i].len) > continue;
For some reason on my computer when I check the formatted patch the ps-> line align with the (seen && ...) line perfectly Again when I send the mail it is shifted forward, I ensured to use tab space instead of 4 spaces as previously asked.
-Jayatheerth