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

Re: [PATCH/RFC] Use regex for :/ matching

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 3, 2007, 18:17 UTC
Message-ID
<7vbq97iqxd.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20071203173022.GA19219@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Mon, Dec 03, 2007 at 10:55:15AM +0000, Johannes Schindelin wrote:
>
>> Except that I did not support ".." (does yours?), _and_ that my patch is 
>> not as nice as yours.
>
> No, I didn't. I'm not sure it is sane, since :/ can contain free-form
> text (and with a regex, .. is not that unlikely). And you can always do
> git-log --not :/foo :/bar
>
>> But then, my patch also works when save_commit_buffer == 0.  But I can 
>> refactor this into its own patch, since it really is a separate issue.
>
> Agreed.

What I found mildly irritating in the current syntax (and that is the primary reason why I use it rarely) is that there is no way to tell it to dig from a particular ref (e.g. "on master branch, find the latest commit whose title matches this string").

For "git-log", you can do "git log master --grep=string -1" to emulate this, and it extends to "git log maint..master --grep=string" to limit the revision ranges and "find all not just latest" very naturally.

Also once we start to talk about supporting "ranges", I suspect the semantics becomes fuzzier, because ":/" is defined as an extended SHA-1 expression that resolves to a single commit. ":/A..:/B" is probably unneeded as you can always say "^:/B :/A", but making ":/A" (we need an extended syntax to differentiate from the singleton case we currently have) to mean "all the commits that match this pattern" is something people might be interested to see. Unfortunately, that does not define a revision range operator but a operator that gives back set of commits that are not consecutive, primarily good for giving to nothing but "git show", and again "git log --grep" would emulate it just as well.

So in short:
 * I do not think extending it to mean a set of commits (with some
   definition of how the set is computed) is a good idea.  It can stay
   "name one commit that matches this string" without losing usefulness,
   and I think it should;
 * The definition of the "match" can be tweaked and introducing regexp
   might be a good way;
 * The definition of the "match" may become more useful if we can limit
   which refs to dig from.
Previous: Jeff KingNext: Jeff King
Message 4 of 11 in “Use regex for :/ matching”
  1. Use regex for :/ matchingJeff King, Dec 3, 2007
  2. Johannes SchindelinDec 3, 2007
  3. Jeff KingDec 3, 2007
  4. Junio C HamanoDec 3, 2007
  5. Jeff KingDec 6, 2007
  6. Junio C HamanoDec 6, 2007
  7. Jeff KingDec 6, 2007
  8. Johannes SchindelinDec 6, 2007
  9. Allow ':/<oneline-prefix>' syntax to work with save_commit_buffer == 0Johannes Schindelin, Dec 3, 2007
  10. Junio C HamanoDec 3, 2007
  11. Johannes SchindelinDec 3, 2007

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.