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

Re: Updated Kernel Hacker's guide to git

From
Junio C Hamano <junkio@cox.net>
Date
Dec 22, 2006, 10:26 UTC
Message-ID
<7vvek41b29.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<38b2ab8a0612220135p6925be4cmf003811f616395ba@mail.gmail.com>
"Francis Moreau" <francis.moro@gmail.com> writes:
Show 7 quoted lines
> I think this part is really confusing. For a new comer, saying that:
>
> 	git diff a b == git diff a..b
>
> is really not intuitive. Maybe just because adding a new symbol ".."
> in git diff command line means (for me) that we're doing a special
> diff. I would never thought by my own that ".." means a simple "to".

We did not originally have "A B"; you were supposed to always say "A..B". But all other SCM had "A B" notation, so we added support for both because doing so was trivial and there is no risk of confusion (because diff is about two points while log is about a set). These two notations are interchangeable for "diff". If it confuses you, you can stick to the "git diff A B" notation. Of if you are like Linus, stick to "A..B" notation. Either way, you can pretend that the other notation does not even exist and be happy ;-).

Yes, users often wondered why "git diff" accepts "A B", "git log" wants "A..B" and "git log A B" is a disaster. But the root cause of the confusion was not about notation but about the conceptual difference (two points vs a set).

I do not think changing the meaning of "diff A..B" to what "diff A...B" means is a good thing. The notation "..." even _looks_ like a magic, and in diff context, what it does _is_ magic (it is magic in log context, too). You are giving two points, but what actually is used as the two points for diff are different from what you gave; in that sense, it is a very good notation. Changing it would confuse and inconvenience people who already understood and got used to the difference between "diff" and "log": diff takes two points, so given usual A..B notation it uses A and B, while log is about a set and means 'the ones reachable from B, excluding the ones reachable from A'; "A...B" is magic and does a magical thing in both "diff" and "log", taking the merge bases between A and B into account.

Previous: Francis MoreauNext: Francis Moreau
Message 11 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.