Re: [PATCHv2 32/36] pathspec: allow querying for attributes
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Nov 9, 2016, 09:57 UTC
- Message-ID
- <CACsJy8BKwvaw8CsorZhoYDw6gxoosv0gPRRpdwW87+YMASCVcA@mail.gmail.com>
- In-Reply-To
- <20161028185502.8789-33-sbeller@google.com>
On Sat, Oct 29, 2016 at 1:54 AM, Stefan Beller <sbeller@google.com> wrote:
Show 10 quoted lines
> The pathspec mechanism is extended via the new > ":(attr:eol=input)pattern/to/match" syntax to filter paths so that it > requires paths to not just match the given pattern but also have the > specified attrs attached for them to be chosen. > > Signed-off-by: Stefan Beller <sbeller@google.com> > Signed-off-by: Junio C Hamano <gitster@pobox.com> > --- > Documentation/glossary-content.txt | 20 +++++ > dir.c | 35 ++++++++
Pathspec can be processed in a couple more places. The big two are match_pathspec and tree_entry_interesting, the former traverses a list while the latter does a tree. You don't have to implement attr matching in tree_entry_interesting right now because nobody needs it, probably. But you need to make sure if somebody accidentally calls tree_entry_interesting with an attr pathspec, then it should die("BUG"), not silently ignore attr.
The way to do that is GUARD_PATHSPEC macro which makes sure if only recognized magic is allowed through. This macro guards all pathspec processing functions. So you can add a new PATHSPEC_ATTR macro (or some other name) to the "Pathspec magic" group near the beginning of pathspec.h, set it whenever attr magic is present when you parse_pathspec(), then lift the GUARD_PATHSPEC restriction in match_pathspec() only because this function can handle it. Whenever attr magic is used by any other functions, it will die() the way we want.
-- Duy