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

[RFC] Using gitrevisions :/search style with other operators

From
Kevin Ballard <kevin@sb.org>
Date
Nov 5, 2010, 22:38 UTC
Message-ID
<9D675671-693D-4B59-AF2A-0EFE4C537362@sb.org>

Most of the ways to refer to a git revision can be combined, e.g. I can type something silly like

  HEAD~2^^2^2~4^{tree}
and this will work as expected.

There is one operator that doesn't allow this at all, and that's the commit message search (e.g. :/foo). Every character after the :/ is taken to be part of the regular expression. This is rather unfortunate as it prevents me from doing something like :/foo^ to refer to the parent of the matching commit.

Does anybody have any opinions on changing this operator? My suggestion would be to treat a second / as a termination of the pattern and allow operators (such as ^ or ~<n>) to occur at that point. This would look like

  :/Merge branch 'foo'/^
If you need a / in your message then you can just escape it with a backslash.

A second change to consider is a syntax to specify that you want the 2nd (or nth) match rather than the first. This could be done like

  :/foo/2
unless someone has a better idea.

And finally, I'd love to be able to specify the ref to search from. The current behavior is to find the earliest matching commit on any ref, but it seems I should be able to type something like

  git merge 'origin/pu:/jh\/notes-merge/^2'

in order to grab the jh/notes-merge topic branch from origin/pu and merge it into HEAD. Currently trying to type something like master:/test will treat /test as a file path on master, which is something that will never resolve to a real file due to the leading slash.

Comments/suggestions/critiques are welcome.
-Kevin Ballard
Next: Junio C Hamano
Message 1 of 6 in “[RFC] Using gitrevisions :/search style with other operators”
  1. Kevin BallardNov 5, 2010
  2. Junio C HamanoNov 8, 2010
  3. Kevin BallardNov 8, 2010
  4. Jeff KingNov 9, 2010
  5. Junio C HamanoNov 9, 2010
  6. Jeff KingNov 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.