From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] exclude: fix a bug in prefix comparison optimization
Date: Sun, 14 Oct 2012 10:36:06 -0700 [thread overview]
Message-ID: <7v8vb9yn09.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1350214522-3242-1-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Sun, 14 Oct 2012 18:35:22 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> When "namelen" becomes zero at this stage, we have matched the fixed
> part, but whether it actually matches the pattern still depends on the
> pattern in "exclude". As demonstrated in t3001, path "three/a.3"
> exists and it matches the "three/a.3" part in pattern "three/a.3[abc]",
> but that does not mean a true match.
>
> Don't be too optimistic and let fnmatch() do the job.
Yeah, the existing code is correct _only_ if the pattern part can
match an empty string (e.g. "three/a.3*") and this is a correct fix.
With your "teach attr.c match the same optimization as dir.c"
series, you would need something like this
diff --git i/attr.c w/attr.c
index 6d39406..528e935 100644
--- i/attr.c
+++ w/attr.c
@@ -710,7 +710,7 @@ static int path_matches(const char *pathname, int pathlen,
* if the non-wildcard part is longer than the remaining
* pathname, surely it cannot match.
*/
- if (!namelen || prefix > namelen)
+ if (prefix > namelen)
return 0;
if (baselen != 0)
baselen++;
Comparing the corresponding code in dir.c, there is no "compare the
literal prefix part with strcmp() before doing the fnmatch()"
optimization. Intended?
(warning: I haven't had my caffeine yet)
next prev parent reply other threads:[~2012-10-14 17:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-14 11:35 [PATCH] exclude: fix a bug in prefix comparison optimization Nguyễn Thái Ngọc Duy
2012-10-14 17:36 ` Junio C Hamano [this message]
2012-10-14 18:25 ` Junio C Hamano
2012-10-15 4:09 ` Nguyen Thai Ngoc Duy
2012-10-15 4:28 ` Junio C Hamano
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=7v8vb9yn09.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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).