Re: ':/<oneline prefix>' notation doesn't support full file syntax
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 3, 2008, 12:38 UTC
- Message-ID
- <alpine.DEB.1.00.0807031333150.9925@racer>
- In-Reply-To
- <279b37b20807030150t2e9cbcc8wf099a5872568af8@mail.gmail.com>
Hi,
On Thu, 3 Jul 2008, Eric Raible wrote:
Show 12 quoted lines
> On Thu, Jul 3, 2008 at 1:34 AM, Junio C Hamano <gitster@pobox.com> wrote: > > "Eric Raible" <raible@gmail.com> writes: > > > > Is there anything to fix? In that example, you are looking for a > > commit that talks about "object name:sha1_name.c" in the comment. > > Yes. What if I'm looking for specific file (i.e. sha1_name.c) in the > commit described by ":/object name:", just like I can do with > 28a4d9404:sha1_name.c? > > This is not ambiguous if we first consider the entire string as the > prefix. If that fails we look for a filename after the final ':'.
It is super-expensive, as you have to look through the whole history just to find that you do not find anything.
And then, it could be that you do find a commit that starts with that string, but what you really wanted it a file, not a commit.
And then, a file name can contain colons. What to do in that case?
I think your "fix" is not worth it. ":/<oneline>" is to help you find a commit, and it will only ever find the first commit anyway, so you are probably better off using
$ git show $(git log --pretty=format:%H:path/to/file.c \ --grep=^<oneline>)
to begin with.
Really, the only reason I ever wrote support for ":/blah" is when someone less-than-helpful says "In commit 'Bla bla bla' you broke XYZ" and I want to $ git show :/Bla
Nowadays, however, I would
$ git log -p --grep=^Bla
so I'd vote to remove the ":/" syntax altogether. We need not even concern ourselves with scripts using that syntax, since the semantics are so limited that nobody should use it in scripts anyway.
Ciao, Dscho