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

Re: [PATCH 0/2] [RFD] Using gitrevisions :/search style with other operators

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 8, 2010, 19:47 UTC
Message-ID
<201012082047.44022.jnareb@gmail.com>
In-Reply-To
<1291820319-12455-1-git-send-email-pclouds@gmail.com>
On Wed, 8 Dec 2010, Nguyễn Thái Ngọc Duy wrote:
Show 11 quoted lines
> Let's start off from where the previous discussion [1] stopped. People
> seem to agree ref^{/regex} is a good choice. But we have not come to
> conclusion how to specify the count yet. Possible suggestions are
> 
>  - ref^{/foo}2
>  - ref^{2/foo}
>  - ref^{:2/foo}
>  - ref^{2nd/foo}
> 
> For whatever syntax chosen, :/ should benefit too. I notice that :/!
> is reserved for future use. Perhaps :/!2/regex is not too cryptic?

I wonder if it would be possible to make :/<regex> (which looks a bit like searching the index) to be an alias to --all^{/<regex>}...

Or if we can make ^{/<regex>} to act on revision range specified by earlier commits, so for example foo..bar^{/<regex>} would work.

> I'd also like to do case-insensitive regex, by the way. :/!2i/regex
> looks a bit ugly.

The '2nd' idea came from Perl 6 regexp / grammars, see for example https://github.com/perlpilot/perl6-docs/blob/master/intro/p6-regex-intro.pod

 There are two other modifiers for matching a pattern some number of times
 or only matching, say, the third time we see a pattern in a string. These
 modifiers are a little strange in that their short-hand forms consist of
 a number followed by some text:
    modifier        short-hand              meaning
    :x()            :1x,:4x,:12x            match some number of times
    :nth()          :1st,:2nd,:3rd,:4th     match only the Nth occurance
 Here are some examples to illustrate these modifiers:
    $_ = "foo bar baz blat";
    m :3x/ a /              # matches the "a" characters in each word
    m :nth(3)/ \w+ /        # matches "baz"

So it could be e.g. 'foo^{:2nd/<regexp>}' (note that there is no trailing / closing regexp, i.e. it is not 'foo^{:2nd/<regexp>/}').

So if we chose this, why don't we follow Perl 6 rule of combining modifiers http://perlcabal.org/syn/S05.html#Modifiers, so it would be

   foo^{:2nd:i/<regexp>}
or
   foo^{:i:nth(2)/<regexp>}

As to :/!<regexp> form: isn't it reserved for non-match? If not, then perhaps

  :/!2nd:i/<regexp>
Show 9 quoted lines
> [1] http://mid.gmane.org/9D675671-693D-4B59-AF2A-0EFE4C537362@sb.org
> 
> Nguyễn Thái Ngọc Duy (2):
>   get_sha1_oneline: allow to input commit_list
>   get_sha1: support ref^{/regex} syntax
> 
>  Documentation/revisions.txt |    7 ++++++
>  sha1_name.c                 |   45 ++++++++++++++++++++++++++++++++----------
>  2 files changed, 41 insertions(+), 11 deletions(-)
Thank you for working on this.
-- 
Jakub Narebski
Poland
Previous: Junio C HamanoNext: Jonathan Nieder
Message 25 of 32 in “[RFD] Using gitrevisions :/search style with other operators”
  1. 0/2 [RFD] Using gitrevisions :/search style with other operatorsNguyễn Thái Ngọc Duy, Dec 8, 2010
  2. 1/2 get_sha1_oneline: allow to input commit_listNguyễn Thái Ngọc Duy, Dec 8, 2010
  3. Thiago FarinaDec 8, 2010
  4. 2/2 get_sha1: support ref^{/regex} syntaxNguyễn Thái Ngọc Duy, Dec 8, 2010
  5. Junio C HamanoDec 8, 2010
  6. Jonathan NiederDec 8, 2010
  7. Jakub NarebskiDec 8, 2010
  8. Nguyen Thai Ngoc DuyDec 9, 2010
  9. Jakub NarebskiDec 9, 2010
  10. Jonathan NiederDec 9, 2010
  11. Kevin BallardDec 9, 2010
  12. Nguyen Thai Ngoc DuyDec 9, 2010
  13. Jonathan NiederDec 9, 2010
  14. Junio C HamanoDec 9, 2010
  15. Jakub NarebskiDec 9, 2010
  16. Nguyen Thai Ngoc DuyDec 10, 2010
  17. Jonathan NiederDec 10, 2010
  18. Jakub NarebskiDec 10, 2010
  19. Kevin BallardDec 10, 2010
  20. Jeff KingDec 10, 2010
  21. Junio C HamanoDec 10, 2010
  22. Kevin BallardDec 10, 2010
  23. Junio C HamanoDec 10, 2010
  24. Junio C HamanoDec 9, 2010
  25. Jakub NarebskiDec 8, 2010
  26. Jonathan NiederDec 8, 2010
  27. Nguyen Thai Ngoc DuyDec 9, 2010
  28. Jakub NarebskiDec 9, 2010
  29. Nguyen Thai Ngoc DuyDec 9, 2010
  30. Kevin BallardDec 9, 2010
  31. Jakub NarebskiDec 9, 2010
  32. Nguyen Thai Ngoc DuyDec 9, 2010

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.