Re: [PATCH] pathspec: rename per-item field has_wildcard to use_wildcard
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:59
Nguyen Thai Ngoc Duy [off-list ref] writes:
2011/4/6 Junio C Hamano [off-list ref]: I have started working on the conversion, but it may take a while because in many places pathspec is still assumed a prefix (and handled separately, which is not good for negative pathspec). Fundamental support for magic pathspec and "top dir" notation probably do not need get_pathspec() converted to struct pathspec.
I think you meant to say "If we only want to have 'top dir' magic,
fundamental support and get_pathspec() conversion are unnecessary", and I
agree 100%.
I am actually tempted to add Michael's hack to get_pathspec() only to
support the "from the top" (and error out with any other magic---as the
approach without a proper restructuring will not work with anything but
that particular magic), to get the "add -u" topic going, and let you (or
other people who are interested in the pathspec rationalization) later fix
it up just a small part of existing issues.
The extensible syntax I have in mind (we only parse in get_pathspec() in
such a tentative version but anything other than the :/ will error out) is
to use:
(1) Colon, a run of selected non-alpha (i.e. magic signature), an
optional colon to terminate the magic signature, followed by the
path, e.g.
- ":/hello.c" is a path from the top.
- ":!/hello.c" is path from the top but no globbing.
- ":/!hello.c" is the same as above.
- ":/::hello.c" is ":hello.c" from the top, the second colon
terminates the magic signature and allows the funny file with a
leading colon to be named.
- "::hello.c" does not have any magic, is the same as "hello.c".
(2) Colon, open parenthesis, a comma separated list of words to name
magic, close parenthesis, followed by the path, e.g. these are the
long-hand counterparts to the examples in (1)
- ":(top)hello.c"
- ":(top,noglob)hello.c"
- ":(noglob,top)hello.c"
- ":(noglob,top):hello.c"
- ":()hello.c"
At this point, I am not interested in building the repertoire of magic
yet, but would want to nail a syntax that is
- concise in common cases (e.g. "from the top, not a funny name" is ':/'
followed by the name);
- is extensible in the future; and
- easy to parse and error out on magic we do not understand.