Thread (12 messages) flat view 12 messages, 5 authors, 2016-06-15

Re: Commit-ish shortcut for immediate parent range

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:45


On Sun, 22 Oct 2006, Andy Parkins wrote:
Git's commit-ish is very powerful.  I was wondering however, if there was a 
shortcut for (for example)?

 git-diff 3435fdb4c^..3435fdb4c

That is - the short range of a particular commit's parent to that commit; like

 git-diff 3435fdb4c!
Umm. That's not actually a very sensible operation. It's only sensible in 
the special case of "diff", and for that special case, what we do is to 
actually just say that the _command_ is special, not the range.

It's called "git show".

So the thing to do is just

	git show 3435fdb4c

and be happy.

Anyway, there's two kinds of commands wrt revision ranges in git:

 - "git diff"
 - everything else

That may sound strange, but it's true. "git diff" doesn't really do 
"revision ranges". It does "two revision endpoints", which is literally 
very different from just about any other git command. All the other 
commands really think of commits as a "set of individual commits" (where 
sometimes the "set" is admittedly just a single commit).

So the reason for you wanting that "3435fdb4c^..3435fdb4c" is not that 
it's a particularly useful thing in _general_, it's that "git diff" wants 
two endpoints, and you want to have that describe a single commit. 

Hopefully this explains why it's the _command_ that is special, and not 
the range. The range makes no sense.

				Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help