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

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
Previous: Francis MoreauNext: Carl Worth
Message 2 of 12 in “Re: Updated Kernel Hacker's guide to git”
  1. Francis MoreauDec 21, 2006
  2. Linus TorvaldsDec 21, 2006
  3. Carl WorthDec 22, 2006
  4. Linus TorvaldsDec 22, 2006
  5. Carl WorthDec 22, 2006
  6. Linus TorvaldsDec 22, 2006
  7. Junio C HamanoDec 22, 2006
  8. Carl WorthDec 22, 2006
  9. Jakub NarebskiDec 22, 2006
  10. Francis MoreauDec 22, 2006
  11. Junio C HamanoDec 22, 2006
  12. Francis MoreauDec 22, 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.