The current solution mentions
Use git diff @{u}...HEAD
, with three dots.
But... this is best done with Git 2.28 (Q3 2020).
Before, "git diff
" used to take arguments in random and nonsense range notation, e.g. "git diff A..B C
", "git diff A..B C...D
", etc., which has been cleaned up.
See commit b7e10b2, commit 8bfcb3a (12 Jun 2020), and commit bafa2d7 (09 Jun 2020) by Chris Torek (chris3torek
).
(Merged by Junio C Hamano -- gitster
-- in commit 1457886, 25 Jun 2020)
git diff
: improve range handling
Signed-off-by: Chris Torek
When git diff
is given a symmetric difference A...B
, it chooses some merge base from the two specified commits (as documented).
This fails, however, if there is no merge base: instead, you see the differences between A and B, which is certainly not what is expected.
Moreover, if additional revisions are specified on the command line ("git diff A...B C
"), the results get a bit weird:
If there is a symmetric difference merge base, this is used as the left side of the diff.
The last final ref is used as the right side.
If there is no merge base, the symmetric status is completely lost.
We will produce a combined diff instead.
Similar weirdness occurs if you use, e.g., "git diff C A...B D
". Likewise, using multiple two-dot ranges, or tossing extra revision specifiers into the command line with two-dot ranges, or mixing two and three dot ranges, all produce nonsense.
To avoid all this, add a routine to catch the range cases and verify that that the arguments make sense.
As a side effect, produce a warning showing which merge base is being used when there are multiple choices; die if there is no merge base.
The documentation now includes:
'git diff' [<options>] <commit> [<commit>...] <commit> [--] [<path>...]
:
This form is to view the results of a merge commit.
The first listed must be the merge itself; the remaining two or more commits should be its parents.
A convenient way to produce the desired set of revisions is to use the {caret}@
suffix.
For instance, if master
names a merge commit, git diff master master^@
gives the same combined diff as git show master
.