From: Jeff King <peff@peff.net>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] add core.pathspecGlob config option
Date: Wed, 19 Dec 2012 22:13:27 -0500 [thread overview]
Message-ID: <20121220031327.GB9917@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8BB3=3ZHD5Ua9M-0+98JVigHBBuo07gBSgEwanvB0zBSA@mail.gmail.com>
On Thu, Dec 20, 2012 at 08:28:57AM +0700, Nguyen Thai Ngoc Duy wrote:
> > So I think this is a nice, simple approach for sites that want it, and
> > noglob magic can come later (and will not be any harder to implement as
> > a result of this patch).
>
> Any chance to make use of nd/pathspec-wildcard? It changes the same
> code path in match_one. If you base on top of nd/pathspec-wildcard,
> all you have to do is assign nowildcard_len to len (i.e. no wildcard
> part).
I'd rather keep it separate for now. One, just because they really are
independent topics, and two, because I am actually back-porting it for
GitHub (we are fairly conservative about upgrading our backend git
versions, as most of the interesting stuff happens on the client side; I
cherry-pick critical patches with no regard to the release cycle).
And the resolution is pretty trivial, too. It looks like this:
diff --cc dir.c
index 5c0e5f6,03ff36b..81cb439
--- a/dir.c
+++ b/dir.c
@@@ -1456,14 -1433,10 +1460,18 @@@ int init_pathspec(struct pathspec *path
item->match = path;
item->len = strlen(path);
- item->nowildcard_len = simple_length(path);
- item->use_wildcard = !limit_pathspec_to_literal() &&
- !no_wildcard(path);
- if (item->use_wildcard)
- pathspec->has_wildcard = 1;
+ item->flags = 0;
- if (item->nowildcard_len < item->len) {
- pathspec->has_wildcard = 1;
- if (path[item->nowildcard_len] == '*' &&
- no_wildcard(path + item->nowildcard_len + 1))
- item->flags |= PATHSPEC_ONESTAR;
++ if (limit_pathspec_to_literal())
++ item->nowildcard_len = item->len;
++ else {
++ item->nowildcard_len = simple_length(path);
++ if (item->nowildcard_len < item->len) {
++ pathspec->has_wildcard = 1;
++ if (path[item->nowildcard_len] == '*' &&
++ no_wildcard(path + item->nowildcard_len + 1))
++ item->flags |= PATHSPEC_ONESTAR;
++ }
+ }
}
qsort(pathspec->items, pathspec->nr,
Not re-indenting the conditional would make the diff more readable, but
I think the resulting code is simpler to read if all of the wildcard
stuff is inside the "else" block.
-Peff
next prev parent reply other threads:[~2012-12-20 3:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 20:34 [PATCH] add core.pathspecGlob config option Jeff King
2012-12-19 20:54 ` Junio C Hamano
2012-12-19 21:09 ` Jeff King
2012-12-19 21:50 ` [PATCH] add GIT_PATHSPEC_GLOB environment variable Jeff King
2012-12-19 22:00 ` Junio C Hamano
2012-12-19 22:12 ` Jeff King
2012-12-19 22:16 ` Junio C Hamano
2012-12-19 22:20 ` Jeff King
2012-12-19 22:37 ` Jeff King
2012-12-19 21:30 ` [PATCH] add core.pathspecGlob config option Junio C Hamano
2012-12-19 21:45 ` Jeff King
2012-12-20 1:28 ` Nguyen Thai Ngoc Duy
2012-12-20 3:13 ` Jeff King [this message]
2012-12-20 3:51 ` Junio C Hamano
2012-12-20 3:55 ` Jeff King
2012-12-20 4:06 ` Jeff King
2012-12-20 4:11 ` Jeff King
2012-12-20 5:26 ` 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=20121220031327.GB9917@sigill.intra.peff.net \
--to=peff@peff.net \
--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).