Subject: Re: [PATCH/RFC v2 0/2] add regex match flags to git describe

From: Junio C Hamano <[email-masked]>
Date: Mon, 28 Dec 2015 12:30:07 -0800

Mostyn Bramley-Moore <[email-masked]> writes:

> git describe currently only supports glob matching with the --matches flag.
> It would be useful to support regular expressions.
>
> For consistency, this uses the same regex flags as those used by git-grep.
>
> Some old discussion of this as a candidate feature is here, though nobody put
> together a patch as far as I can see:
> http://comments.gmane.org/gmane.comp.version-control.git/173873

Thanks.

I do not think it is wrong per-se to add an option to use regular
expressions instead of globs, but if we are to do so, the endgame we
aim for MUST be that we do so consistently to all the other commands
that iterate over refs and limit their output to the ones that match
given pattern (or a set of patterns), not just 'describe'.

Even if we are not adding such an option to these other commands
right now (yet), we at least need to know what these commands are
(e.g. "git tag -l" and "git for-each-ref" immediately come to mind,
but there may be others), and make sure that the option names you
choose here can be used sensibly in their context.  I think "tag"
and "for-each-ref" do no pattern matching against anything other
than the refnames, so it would be clear what a new --perl-regexp
option does in their contexts.

Unlike "grep" whose sole point is to perform pattern matching, the
filtering of refs these commands do is merely a very small tweak in
the overall picture (e.g. "git tag --contains $commit -l $pattern"
does filter by matching $pattern against the refname, but that is a
small detail compared to the filtering done by the reachability with
the $commit), so I am not sure if short -E/-G/-F/-P should be given
to these commands like "grep" does, though.  These commands may have
better uses for these shorter option names.