Re: Updated Kernel Hacker's guide to git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 21 Dec 2006, Francis Moreau wrote:
> 
> 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]