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

Re: Tentative built-in "git show"

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 15, 2006, 20:57 UTC
Message-ID
<Pine.LNX.4.64.0604151345050.3701@g5.osdl.org>
In-Reply-To
<7v3bgefxkp.fsf@assigned-by-dhcp.cox.net>
On Sat, 15 Apr 2006, Junio C Hamano wrote:
> 
> I sometimes do "git show -4" myself, and wondered why defaulting
> to "-n 1"is insufficient

I detest -n1 for a variety of reasons, and giving multiple refs is just one of them.

The reason I like "--no-walk" is that it's conceptually much stronger, and more efficient. Remember how we tried to optimize "-1" (as used by gitweb) by adding magic special cases to get_revision()? And how they always ended up being problematic because of how they interact with all the other options?

So we don't do it any more, and as a result, "git-rev-list -1 HEAD" will actually walk all the parents too.

In contrast, "--no-walk" just does exactly what you tell it: don't start walking the parents. It's kind of equivalent to -1 with one argument, but in the presense of path limiting it actually does the RightThing(tm), unlike -1.

Try this as a replacement for "git show":
	git log -1 kernel/
	git log --no-walk kernel/

on the current kernel source tree to see the difference. "--no-walk" gives the right answer (for some definition of "right"). While -1 gives a totally random answer that has nothing to do with the current HEAD (except that it's _reachable_ from the current HEAD).

So I think "-n 1" is fundamentally incompatible with "git show". Git "show" is "show _this_ commit". While "-1" fundamentally means "show the _first_ commit when you walk the tree". Which is really really fundamentally different.

In contrast "--no-walk" tells you exactly what it is about. Don't walk the tree. Show _this_ commit.

(Now, the reason I said 'for _some_ definition of "right"' is that the question about path limiting in the absense of commit walking is somewhat ambiguous. The current "git show" shows the commit regardless. My suggested patch will potentially prune the commit away, and if the specified commit does not touch the path, no commit is shown at all. Both make sense. While "git-rev-list -1" does _not_ make sense)

			Linus
Previous: Junio C Hamano
Message 3 of 3 in “Tentative built-in "git show"”
  1. Linus TorvaldsApr 15, 2006
  2. Junio C HamanoApr 15, 2006
  3. Linus TorvaldsApr 15, 2006

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.