Re: [PATCHv2 1/4] refs: add common refname_match_patterns()
From: Tom Grennan <hidden>
Date: 2016-06-15 22:53:03
On Mon, Feb 13, 2012 at 06:00:40AM +0100, Michael Haggerty wrote:
On 02/11/2012 08:17 PM, Tom Grennan wrote:quoted
Yes, I didn't explicitly state that the precedence is the order written and in correctly described the first case. How about? /** * Returns in highest to lowest precedence: * 1 with an empty patterns list * 0 if refname fnmatch()es any ^ prefaced pattern * 1 if refname fnmatch()es any other pattern * 0 otherwise */Much better; thanks. Please note that this choice of semantics limits its power. For example, if the rule were instead (like with gitattributes(5)) "if more than one pattern matches a refname, a later pattern overrides an earlier pattern", then one could do things like refs/remotes/*/* !refs/remotes/gitster/* refs/remotes/gitster/master to include specific references within a hierarchy that is otherwise excluded. However, since rev-list apparently uses a rule more like the one that you are proposing, it might be better to be consistent than to choose a different convention.
Hmm, I think it's important to have same respective result in each of
these case's,
$ git tag -l | grep v1.7.8.*
$ git tag -l v1.7.8*
$ git tag -l | grep -v .*-rc*
$ git tag -l ^*-rc*
$ git tag -l v1.7.8* | grep -v .*-rc*
$ git tag -l v1.7.8* ^*-rc*
$ git tag -l ^*-rc* v1.7.8*
What I propose is somewhat analogous to gitignore's double negative,
* An optional prefix ! which negates the pattern; any matching
file excluded by a previous pattern will become included again. If
a negated pattern matches, this will override lower precedence
patterns sources.
I still prefer "^" to "!" b/c A) it doesn't cause the noted regressions;
and B) doesn't need command quoting. I'd accept the counter proposals
of --exclude or --with[out][-TYPE] but frankly, that's more
code/documentation churn ("less code is always better"[TM]) and worse,
more crap to type on the command line:
$ git --with-tags v1.7.8* --without-tags '*-rc*' tag -l v1.7.8*
or
$ git tag -l --exclude '*-rc*' v1.7.8*
vs.
$ git tag -l v1.7.8* ^*-rc*
--
TomG