git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org,  Jeff King <peff@peff.net>,
	 Elijah Newren <newren@gmail.com>,
	 Patrick Steinhardt <ps@pks.im>,  SURA <surak8806@gmail.com>
Subject: Re: [PATCH v2 2/2] refs.c: stop matching non-directory prefixes in exclude patterns
Date: Thu, 06 Mar 2025 09:27:21 -0800	[thread overview]
Message-ID: <xmqqjz92hxxi.fsf@gitster.g> (raw)
In-Reply-To: <67c8c5f797833a9a35f4805059d7e759020f54bd.1741275245.git.me@ttaylorr.com> (Taylor Blau's message of "Thu, 6 Mar 2025 10:34:53 -0500")

Taylor Blau <me@ttaylorr.com> writes:

> So there is a subtle bug with '--exclude' which is that in the
> packed-refs backend we will consider "refs/heads/bar" to be a pattern
> match against "refs/heads/ba" when we shouldn't. Likewise, the reftable
> backend (which in this case is bug-compatible with the packed backend)
> exhibits the same broken behavior.
> ...
> There is some minor test fallout in the "overlapping excluded regions"
> test, which happens to use 'refs/ba' as an exclude pattern, and expects
> references under the "refs/heads/bar/*" and "refs/heads/baz/*"
> hierarchies to be excluded from the results.
>
> ... test (since the range is no longer
> overlapping under the stricter interpretation of --exclude patterns
> presented here).

The code change, reasoning, and the tests look all good.  It just
leaves a bit awkward aftertaste.

In general, I think our "we have a tree-like structure with patterns
to match paths" code paths, like pathspec matching, are structured
in such a way that the low level is expected to merely cull
candidates early as a performance optimization measure (in other
words, they are allowed false positives and say something matches
when they do not, but not allowed false negatives) and leave the
upper level to further reject the ones that do not match the
pattern.  If packed-refs backend was too loose in its matching and
erroneously considered that refs/heads/bar matched refs/heads/ba
pattern, I would naïvely expect that the upper layer would catch and
reject that refs/heads/bar as not matching.

Apparently that was not happening and that is why we need this fix?

Is the excluded region optimization expected to be powerful enough
to cover all our needs so that we do not need to post-process what
it passes?

Thanks.  

  reply	other threads:[~2025-03-06 17:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06  1:19 [PATCH 0/2] refs: a couple of --exclude fixes Taylor Blau
2025-03-06  1:19 ` [PATCH 1/2] refs.c: remove empty '--exclude' patterns Taylor Blau
2025-03-06  1:19 ` [PATCH 2/2] refs.c: unify '--exclude' behavior between files and packed backends Taylor Blau
2025-03-06  8:47   ` Patrick Steinhardt
2025-03-06 14:54     ` Taylor Blau
2025-03-06 15:34 ` [PATCH v2 0/2] refs: a couple of --exclude fixes Taylor Blau
2025-03-06 15:34   ` [PATCH v2 1/2] refs.c: remove empty '--exclude' patterns Taylor Blau
2025-03-07 21:32     ` Elijah Newren
2025-03-07 23:37       ` Taylor Blau
2025-03-07 23:58         ` Elijah Newren
2025-03-06 15:34   ` [PATCH v2 2/2] refs.c: stop matching non-directory prefixes in exclude patterns Taylor Blau
2025-03-06 17:27     ` Junio C Hamano [this message]
2025-03-07  9:35       ` Patrick Steinhardt
2025-03-07 17:31         ` Junio C Hamano
2025-03-07 23:42           ` Taylor Blau
2025-03-07 21:31     ` Elijah Newren
2025-03-07 23:46       ` Taylor Blau

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=xmqqjz92hxxi.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=surak8806@gmail.com \
    /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).