git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, lucasseikioshiro@gmail.com, peff@peff.net,
	 piotrsiupa@gmail.com, sandals@crustytoothpaste.net
Subject: Re: [PATCH] dir.c: literal match with wildcard in pathspec should still glob
Date: Sat, 3 May 2025 11:54:40 +0530	[thread overview]
Message-ID: <CA+rGoLfFCi-q52ABUr=0O=pu+qSikcomSk1akHWUkfAfSf=pZg@mail.gmail.com> (raw)
In-Reply-To: <20250503060736.587286-1-jayatheerthkulkarni2005@gmail.com>

On Sat, May 3, 2025 at 11:37 AM K Jayatheerth
<jayatheerthkulkarni2005@gmail.com> wrote:
>
> 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

  reply	other threads:[~2025-05-03  6:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 16:05 [PATCH v2] Dir: Fix and test wildcard pathspec handling K Jayatheerth
2025-04-22 18:53 ` Junio C Hamano
2025-05-03  6:07   ` [PATCH] dir.c: literal match with wildcard in pathspec should still glob K Jayatheerth
2025-05-03  6:24     ` JAYATHEERTH K [this message]
2025-05-05 14:41       ` Junio C Hamano
2025-05-05 15:02         ` K Jayatheerth
2025-05-05 15:03         ` JAYATHEERTH K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+rGoLfFCi-q52ABUr=0O=pu+qSikcomSk1akHWUkfAfSf=pZg@mail.gmail.com' \
    --to=jayatheerthkulkarni2005@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lucasseikioshiro@gmail.com \
    --cc=peff@peff.net \
    --cc=piotrsiupa@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).