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
Duy Nguyen <pclouds@gmail.com>
Date
Jan 6, 2016, 12:23 UTC
Message-ID
<CACsJy8AOxs9EizWabdPdEpx6PkPFmv-ZiAtQbdXWV9zDia13Lw@mail.gmail.com>
In-Reply-To
<568C690C.7050007@opera.com>
On Wed, Jan 6, 2016 at 8:08 AM, Mostyn Bramley-Moore <mostynb@opera.com> wrote:
Show 41 quoted lines
> On 01/04/2016 06:46 PM, Junio C Hamano wrote:
>>>> 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
>>
>>
>> Even though we have DWIM between revisions and paths on the command
>> line when the user omits "--" for disambiguation, I do not think we
>> look at the shape of the string to DWIM/decide that it is a pattern,
>> so as long as the magic syntax cannot be a valid pattern to match
>> against refs right now (and your ":(?...)"  qualifies as such, as a
>> refname would not contain a component that begins with a colon), it
>> would be possible to introduce it as the magic syntax for matching
>> refs.
>>
>> Or did you mean to use this syntax also for patterns that match
>> strings in contents, e.g.
>>
>>      $ git grep -e ':(?perl-regexp)...'
>
>
> I think it would be nice to support this syntax in every command that does
> pattern matching.
>
> Corner case: what if we want to search for ":(?perl-regexp)", eg in git's
> own source?  I suppose this would do:
> git grep -e ":(?fixed-strings):(?perl-regexp)"

We can also override it with command line options. If you define --perl-regexp as "if no regex syntax is specified in the pattern, pcre is used", then you can have something like --force-perl-regexp that says "all patterns are in pcre, there's no magic whatsoever to choose a different regex syntax". Though I think --perl-regexp should play the role of --force-perl-regexp so you don't surprise current scripts, and have a new option --default-syntax=<type> instead.

-- 
Duy
Previous: Mostyn Bramley-Moore
Message 14 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.