From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Matthew Hughes <mhughes@uw.co.uk>
Subject: Re: [PATCH 2/2] dir: do not feed path suffix to pathspec match
Date: Sat, 8 Jul 2023 09:16:14 +0200 [thread overview]
Message-ID: <f592e7c9-2a73-41f3-02a5-d77b7be574f1@web.de> (raw)
In-Reply-To: <20230707220457.3655121-3-gitster@pobox.com>
Am 08.07.23 um 00:04 schrieb Junio C Hamano:
> diff --git a/dir.c b/dir.c
> index 3acac7beb1..6116022ae6 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -488,9 +476,6 @@ static int do_match_pathspec(struct index_state *istate,
> return 0;
> }
>
> - name += prefix;
> - namelen -= prefix;
> -
> for (i = ps->nr - 1; i >= 0; i--) {
> int how;
>
> @@ -506,8 +491,8 @@ static int do_match_pathspec(struct index_state *istate,
> */
> if (seen && ps->items[i].magic & PATHSPEC_EXCLUDE)
> seen[i] = MATCHED_FNMATCH;
> - how = match_pathspec_item(istate, ps->items+i, prefix, name,
> - namelen, flags);
> + how = match_pathspec_item(istate, ps->items+i,
> + name, namelen, flags);
With that, the parameter "prefix" of do_match_pathspec() becomes unused
and can be removed. This cascades to match_pathspec_with_flags(),
match_pathspec(), dir_path_match() and builtin/add.c::prune_directory(),
and fill_directory() can lose its return value.
The code continues here like this, though:
if (ps->recursive &&
(ps->magic & PATHSPEC_MAXDEPTH) &&
ps->max_depth != -1 &&
how && how != MATCHED_FNMATCH) {
int len = ps->items[i].len;
if (name[len] == '/')
len++;
if (within_depth(name+len, namelen-len, 0, ps->max_depth))
how = MATCHED_EXACTLY;
else
how = 0;
}
And "name" here would be affected by "prefix" no longer being added.
Does it fix or break --max-depth? I think neither: builtin/grep.c --
the only user of PATHSPEC_MAXDEPTH AFAICS -- passes a prefix of 0.
René
prev parent reply other threads:[~2023-07-08 7:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 22:04 [PATCH 0/2] Fix attr magic combined with pathspec prefix Junio C Hamano
2023-07-07 22:04 ` [PATCH 1/2] t6135: attr magic with path pattern Junio C Hamano
2023-07-07 22:04 ` [PATCH 2/2] dir: do not feed path suffix to pathspec match Junio C Hamano
2023-07-07 23:45 ` [PATCH 2/2alt] " Junio C Hamano
2023-07-08 7:16 ` René Scharfe
2023-07-08 21:35 ` [PATCH 2alt/2] dir: match "attr" pathspec magic with correct paths Junio C Hamano
2023-07-09 5:35 ` René Scharfe
2023-07-09 9:28 ` Junio C Hamano
2023-07-08 7:16 ` René Scharfe [this message]
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=f592e7c9-2a73-41f3-02a5-d77b7be574f1@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhughes@uw.co.uk \
/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).