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

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

Previous: Eric RaibleNext: Dana How
Message 4 of 9 in “':/<oneline prefix>' notation doesn't support full file syntax”
  1. Eric RaibleJul 3, 2008
  2. Junio C HamanoJul 3, 2008
  3. Eric RaibleJul 3, 2008
  4. Johannes SchindelinJul 3, 2008
  5. Dana HowJul 3, 2008
  6. Junio C HamanoJul 3, 2008
  7. Johannes SchindelinJul 4, 2008
  8. Johannes SchindelinJul 4, 2008
  9. Jeff KingJul 3, 2008

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.