git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Arnaud Bertrand <xda@abalgo.com>
To: git@vger.kernel.org
Subject: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)
Date: Mon, 23 Dec 2019 13:51:12 +0100	[thread overview]
Message-ID: <CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com> (raw)

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

             reply	other threads:[~2019-12-23 13:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-23 12:51 Arnaud Bertrand [this message]
2019-12-23 18:02 ` Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com \
    --to=xda@abalgo.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).