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

Re: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 23, 2019, 18:02 UTC
Message-ID
<xmqqy2v26hu0.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com>

Please unlearn dot-dot and three-dots when using "git diff", which is not about ranges but about comparing two endpoints. If we were reinventing Git today from scratch, we would make "git diff A..B" an error. You can consider it a bug that the command accepts a range notation, but this will not change any time soon without a large fight to find and fix uses of the syntax in scripts by longtime Git users have written over the years.

Allowing dot-dot on the command line of "git diff", instead of diagnosing them as errors and dying, was a stupid mistake we (well, mostly Linus, but I am willing to take the blame too) made due to laziness when we reused the machinery, which we invented to parse the command line of "log" family of commands to specify ranges, to parse the command line of "diff", which accidentally ended up allowing the syntax for ranges where it shouldn't be allowed.

And worse yet, since there was only dot-dot and three-dots came much later, "git diff A..B" ended up comparing the endpoints A and B, because there didn't even A...B notation exist.

This is not limited to you but any user of modern Git is better off to pretend "git diff A..B" does not exist; please unlearn dot-dot and three-dots when using "git diff" and you'd be happier.

Previous: Arnaud BertrandNext: Kevin Daudt
Message 2 of 5 in “Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)”
  1. Arnaud BertrandDec 23, 2019
  2. Junio C HamanoDec 23, 2019
  3. Kevin DaudtDec 23, 2019
  4. Jonathan NiederDec 23, 2019
  5. Junio C HamanoDec 23, 2019

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.