git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
MBMostyn Bramley-Moore <mostynb@opera.com>
Date
Dec 31, 2015, 10:07 UTC
Message-ID
<5684FE61.4010701@opera.com>
In-Reply-To
<xmqqy4cbbh5e.fsf@gitster.mtv.corp.google.com>
On 12/31/2015 01:23 AM, Junio C Hamano wrote:
Show 24 quoted lines
> Mostyn Bramley-Moore <mostynb@opera.com> writes:
>
>> OK, brainstorming a bit, how about either of these:
>>
>> 1)
>> --match-pattern-type=<glob|fixed-strings|basic-regexp|extended-regexp|perl-regexp>
>>
>> It's a bit lengthy (maybe --match-type would be sufficient), but I
>> like that the value names are shared with git grep etc option names.
>> And it seems future-proof- if we ever need to support different
>> pattern types for other arguments, a --foo-pattern-type flag could be
>> added and make obvious sense.
>
> Swapping the option key and value may not be a bad idea, but one
> problem that the above does not solve, which I outlined in the
> message you are responding to, is that "match-pattern-type" does not
> give any hint that this is about affecting the match that is done to
> "refs", e.g. you cannot tell in
>
>    $ git mgrep --match-pattern-type=perl-regexp -e foo --refs 'release_*'
>
> if the perl-regexp is to be used for matching branch names or for
> matching the strings the command looks for in the trees of the
> matching branches.
There is a hint: --foo-pattern-type applies only to --foo.

In your mgrep example --match-pattern-type would apply to --match patterns only, and if we choose to implement it then --refs-pattern-type would apply to --refs patterns only.

eg: $ git mgrep --match '^foo' --match-pattern-type=perl-regexp --refs 'release_*' --refs-pattern-type=glob

Show 12 quoted lines
> Magic pattern annotation like we do for pathspecs Duy raised may not
> be a bad idea, either, and would probably be easier to teach people.
> Just like in Perl "(?i)$any_pattern" is a way to introduce the case
> insensitive match with $any_pattern, we may be able to pick an
> extensible magic syntax and decorate the pattern you would specify
> for matching refnames to tell Git what kind of pattern it is, e.g.
>
>    $ git mgrep -P -e foo --refs '/?glob/release_*'
>
> I am not suggesting that we must use /?<pattern type name>/ prefix
> as the "extensible magic syntax" here--I am just illustrating what
> I mean by "extensible magic syntax".

I hadn't seen the pathspec magic patterns before- interesting. We could possibly share syntax with pathspecs, ie :(?pattern-options...)pattern

Would this be confusing for commands that already have --perl-regexp etc? What should happen if you specify both --perl-regexp and and a different type of pattern like :(glob)foo (error out, I suppose)?

-Mostyn.
-- 
Mostyn Bramley-Moore
TV and Connected Devices
Opera Software ASA
mostynb@opera.com
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 14 in “add regex match flags to git describe”
  1. 0/2 add regex match flags to git describeMostyn Bramley-Moore, Dec 28, 2015
  2. 1/2 describe: add option to use perl-compatible regexes with --matchMostyn Bramley-Moore, Dec 28, 2015
  3. 2/2 describe: add basic and extended posix regex matching for completenessMostyn Bramley-Moore, Dec 28, 2015
  4. Junio C HamanoDec 28, 2015
  5. Mostyn Bramley-MooreDec 29, 2015
  6. Junio C HamanoDec 29, 2015
  7. Duy NguyenDec 30, 2015
  8. Mostyn Bramley-MooreDec 31, 2015
  9. Mostyn Bramley-MooreDec 31, 2015
  10. Junio C HamanoDec 31, 2015
  11. Mostyn Bramley-MooreDec 31, 2015
  12. Junio C HamanoJan 4, 2016
  13. Mostyn Bramley-MooreJan 6, 2016
  14. Duy NguyenJan 6, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.