git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)
@ 2019-12-23 12:51 Arnaud Bertrand
  2019-12-23 18:02 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Arnaud Bertrand @ 2019-12-23 12:51 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-23 22:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23 12:51 Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation) Arnaud Bertrand
2019-12-23 18:02 ` Junio C Hamano
2019-12-23 18:29   ` Kevin Daudt
2019-12-23 21:59     ` Jonathan Nieder
2019-12-23 22:10     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).