git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Using gitrevisions :/search style with other operators
@ 2010-11-05 22:38 Kevin Ballard
  2010-11-08 19:09 ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Kevin Ballard @ 2010-11-05 22:38 UTC (permalink / raw)
  To: Git mailing list

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

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [RFC] Using gitrevisions :/search style with other operators
@ 2010-11-09  7:30 Yann Dirson
  2010-11-09  8:06 ` Kevin Ballard
  2010-11-09 16:10 ` Jeff King
  0 siblings, 2 replies; 18+ messages in thread
From: Yann Dirson @ 2010-11-09  7:30 UTC (permalink / raw)
  To: git list, Jeff King, kevin

Jeff wrote:
> It seems to me the natural way to do that would be to use our existing
> generic "start at this ref and follow some chain" syntax, which is
> ref^{foo}. For example: origin/pu^{:Merge 'kb/blame-author-email'}.

We may want to keep the "/" mnemonic (which seems no to conflict
withcurrent use either), rather than the ":" part, with something like
origin/pu^{/Merge 'kb/blame-author-email'}, and keep ":" for future use.

> We also have ref@{upstream}. The analogue here would be
> origin/pu@{:Merge 'kb/blame-author-email'}.

That's somewhat different, it looks like the foo@{...} only applies to
references with name "foo", and not to arbitrary revisions.  Allowing a
search to start from any commit seems more useful here.

Kevin wrote:
> Junio wrote:
> >    $ git log 'HEAD..:( :/Merge branch 'kb/blame-author-email' )^2'
[...]
>
> Interesting idea. It certainly solves the problem of being able to
> embed it within other operations (though you do then have to worry
> about escaping any embedded close-parens in the search), though it
> does mean my suggestion for being able to select the 2nd (or nth)
> match won't work.

Syntax like origin/pu^{/Merge 'kb/blame-author-email'}2 would be
somewhat consistent with the commit^2 case, and would seem unambiguous
as well - a bit weird, though.

-- 
Yann Dirson - Bertin Technologies

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-11-10 18:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05 22:38 [RFC] Using gitrevisions :/search style with other operators Kevin Ballard
2010-11-08 19:09 ` Junio C Hamano
2010-11-08 22:11   ` Kevin Ballard
2010-11-09  5:16     ` Jeff King
2010-11-09 15:59       ` Junio C Hamano
2010-11-09 16:08         ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2010-11-09  7:30 Yann Dirson
2010-11-09  8:06 ` Kevin Ballard
2010-11-09  9:24   ` Yann Dirson
2010-11-10  0:18     ` Junio C Hamano
2010-11-10  0:33       ` Kevin Ballard
2010-11-10  7:32         ` Yann Dirson
2010-11-10  7:46           ` Kevin Ballard
2010-11-10  7:46             ` Yann Dirson
2010-11-10 15:26               ` Jakub Narebski
2010-11-10 17:23                 ` Junio C Hamano
2010-11-10 18:19                   ` Jakub Narebski
2010-11-09 16:10 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).