Re: Updated Kernel Hacker's guide to git
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Dec 21, 2006, 18:23 UTC
- Message-ID
- <Pine.LNX.4.64.0612211013500.3394@woody.osdl.org>
- In-Reply-To
- <38b2ab8a0612210424o4ec5fcd5kb5086c52ccd76491@mail.gmail.com>
On Thu, 21 Dec 2006, Francis Moreau wrote:
Show 9 quoted lines
> > I must really miss something but is a diff between origin and driver heads > achieved by: > > $ git diff driver origin > > instead of: > > $ git diff origin..driver
No.
git diff origin driver
and
git diff origin..driver
is exactly the same thing.
> From the git-rev-list documentation I can read that: > > git-rev-list origin..driver == git-rev-list driver ^origin
Correct. However, "git diff" is very aware of things like "^origin", and understands that
git diff driver ^origin
is the same thing as saying "I want what is in driver, but not in origin", so it needs to switch the arguments.
In short, for git diff (and ONLY) git diff, all of these are the same:
git diff a..b git diff a b git diff b ^a
[ ADDITIONALLY git diff _also_ has a magic special case of
git diff a b ^c
which actually means the same as "git diff c..a" (and "b" is totally ignored). That may sound strange, but it's because the expression "a...b" means "b a --not $(git-merge-base a b)", and so what you actually WANT is that if you do
git diff a...b
you should get "diff from merge-base to b", so when "a...b" expands to "b a ^merge-base", then git understands that if it gets that stange command line with THREE commits, and one of them is negated, you really wanted the diff from the negated one to the first one ]
It basically all boils down to:
"git diff" is special
exactly because unlike almost ALL other git commands, "git diff" does not work on a _list_ of commits, it only works on two end-points. That means that the "list operations" actually end up meaning something else for git diff than they do for "git log" and friends.
Linus