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

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

From
ABArnaud Bertrand <xda@abalgo.com>
Date
Dec 23, 2019, 12:51 UTC
Message-ID
<CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com>
Hello,
Git Version 2.24.0.windows.2

Summary: triple dots git diff L...R -- foo <=> diff between CommonAncestror(L,R) to R git log L...R <=> all commit from L to R

double dots git diff L..R -- foo <=> diff between L and R git log L..R <=> commit from CommonAncestror(L,R) to R

So, to make the command related to the common ancestor, git diff uses the triple dots notation by opposite to git log that uses the double dots notation

In details ------------ ####################################################### The ... (triple dots notation) In the diff context, the triple dots notation is related to the common ancestror:

git diff L...R -- foo

means diff between (common ancestor of L and R) and R is equivalent to:

git diff $(git merge-base L R) R -- foo

But now, if I use the same notation for git log, it means all the commit that differ from L to R

Example, you can execute the following lines:

mkdir test cd test git init echo common > foo git add foo git ci -m "add common part" git switch -c L echo LeftPart >> foo git ci -am "add a left part" git switch master git switch -c R echo "right part" >> foo git ci -am "add a right part" git switch master git diff L...R -- foo

And verify: $ git diff L...R -- foo

diff --git a/foo b/foo
index 30e1159..2570fa8 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
 common
+right part


As expected, only the right part appears.

 and now with the log:
$ git log --oneline --left-right L...R
> f2f11c4 (tag: R) R: add a right part
< 7f4f3d6 (tag: L)  L: add a left part

The log that concers the left part appears too!

##################################################################

If now we consider the .. (double dots notation), it is exactly the opposite!
$ git diff L..R -- foo
diff --git a/foo b/foo
index 6f2cf25..2570fa8 100644
--- a/foo
+++ b/foo
@@ -1,2 +1,2 @@
 common
-LeftPart
+right part


It is clear that both branches differences appear

and with git log:
$ git log --oneline --left-right L..R
> f2f11c4 (tag: R) R: add a right part

For the log, only the commit from the common ancestror to R appear !

So there is well an incoherence between diff and log using the
multi-dots notation


Best regards,

Arnaud Bertrand
Next: Junio C Hamano
Message 1 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.