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

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

 



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



[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]

  Powered by Linux