git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: K JayatheerthNext: Junio C Hamano
Message 4 of 7 in “Dir: Fix and test wildcard pathspec handling”
  1. Dir: Fix and test wildcard pathspec handlingK Jayatheerth, Apr 22, 2025
  2. Junio C HamanoApr 22, 2025
  3. dir.c: literal match with wildcard in pathspec should still globK Jayatheerth, May 3, 2025
  4. JAYATHEERTH KMay 3, 2025
  5. Junio C HamanoMay 5, 2025
  6. dir.c: literal match with wildcard in pathspec should still globK Jayatheerth, May 5, 2025
  7. JAYATHEERTH KMay 5, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.