{"thread":{"id":"52510","subject":"Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","startedAt":"2019-12-23T13:14:51Z","lastAt":"2019-12-23T22:10:14Z","messageCount":5,"participants":["Arnaud Bertrand","Junio C Hamano","Kevin Daudt","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388805","messageId":"CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com","threadId":"52510","inReplyTo":null,"subject":"Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","fromName":"Arnaud Bertrand","fromEmail":"xda@abalgo.com","sentAt":"2019-12-23T12:51:12Z","receivedAt":"2019-12-23T13:14:51Z","isPatch":false,"sender":{"key":"xda@abalgo.com","avatar":null},"body":"Hello,\n\nGit Version 2.24.0.windows.2\n\nSummary:\ntriple dots\ngit diff L...R -- foo    <=> diff between CommonAncestror(L,R) to R\ngit log L...R            <=> all commit from L to R\n\ndouble dots\ngit diff L..R -- foo    <=> diff between L and R\ngit log L..R            <=> commit from CommonAncestror(L,R) to R\n\nSo, to make the command related to the common ancestor, git diff uses\nthe triple dots notation  by opposite to git log that uses the double\ndots notation\n\n\n\nIn details\n------------\n#######################################################\nThe ... (triple dots notation)\nIn the diff context, the triple dots notation is related to the common\nancestror:\n\ngit diff L...R -- foo\n\nmeans diff between (common ancestor of L and R) and R\nis equivalent to:\n\ngit diff $(git merge-base L R) R -- foo\n\nBut now, if I use the same notation for git log, it means all the\ncommit that differ from L to R\n\nExample, you can execute the following lines:\n\nmkdir test\ncd test\ngit init\necho common > foo\ngit add foo\ngit ci -m \"add common part\"\ngit switch -c L\necho LeftPart >> foo\ngit ci -am \"add a left part\"\ngit switch master\ngit switch -c R\necho \"right part\" >> foo\ngit ci -am \"add a right part\"\ngit switch master\ngit diff L...R -- foo\n\n\nAnd verify:\n$ git diff L...R -- foo\ndiff --git a/foo b/foo\nindex 30e1159..2570fa8 100644\n--- a/foo\n+++ b/foo\n@@ -1 +1,2 @@\n common\n+right part\n\n\nAs expected, only the right part appears.\n\n and now with the log:\n$ git log --oneline --left-right L...R\n> f2f11c4 (tag: R) R: add a right part\n< 7f4f3d6 (tag: L)  L: add a left part\n\nThe log that concers the left part appears too!\n\n##################################################################\n\nIf now we consider the .. (double dots notation), it is exactly the opposite!\n$ git diff L..R -- foo\ndiff --git a/foo b/foo\nindex 6f2cf25..2570fa8 100644\n--- a/foo\n+++ b/foo\n@@ -1,2 +1,2 @@\n common\n-LeftPart\n+right part\n\n\nIt is clear that both branches differences appear\n\nand with git log:\n$ git log --oneline --left-right L..R\n> f2f11c4 (tag: R) R: add a right part\n\nFor the log, only the commit from the common ancestror to R appear !\n\nSo there is well an incoherence between diff and log using the\nmulti-dots notation\n\n\nBest regards,\n\nArnaud Bertrand\n"},{"id":"388811","messageId":"xmqqy2v26hu0.fsf@gitster-ct.c.googlers.com","threadId":"52510","inReplyTo":"CAEW0o+gYqWT5u-Tf8aDoMgXaf36Mb-XOApLNs4D+GMVLvsOjxg@mail.gmail.com","subject":"Re: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-23T18:02:31Z","receivedAt":"2019-12-23T18:02:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Please unlearn dot-dot and three-dots when using \"git diff\", which\nis not about ranges but about comparing two endpoints.  If we were\nreinventing Git today from scratch, we would make \"git diff A..B\" an\nerror.  You can consider it a bug that the command accepts a range\nnotation, but this will not change any time soon without a large\nfight to find and fix uses of the syntax in scripts by longtime Git\nusers have written over the years.\n\nAllowing dot-dot on the command line of \"git diff\", instead of\ndiagnosing them as errors and dying, was a stupid mistake we (well,\nmostly Linus, but I am willing to take the blame too) made due to\nlaziness when we reused the machinery, which we invented to parse\nthe command line of \"log\" family of commands to specify ranges, to\nparse the command line of \"diff\", which accidentally ended up\nallowing the syntax for ranges where it shouldn't be allowed.\n\nAnd worse yet, since there was only dot-dot and three-dots came much\nlater, \"git diff A..B\" ended up comparing the endpoints A and B,\nbecause there didn't even A...B notation exist.\n\nThis is not limited to you but any user of modern Git is better off\nto pretend \"git diff A..B\" does not exist; please unlearn dot-dot\nand three-dots when using \"git diff\" and you'd be happier.\n"},{"id":"388812","messageId":"20191223182939.GB676947@alpha","threadId":"52510","inReplyTo":"xmqqy2v26hu0.fsf@gitster-ct.c.googlers.com","subject":"Re: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","fromName":"Kevin Daudt","fromEmail":"kdaudt@alpinelinux.org","sentAt":"2019-12-23T18:29:39Z","receivedAt":"2019-12-23T18:42:17Z","isPatch":false,"sender":{"key":"kdaudt@alpinelinux.org","avatar":null},"body":"On Mon, Dec 23, 2019 at 10:02:31AM -0800, Junio C Hamano wrote:\n> Please unlearn dot-dot and three-dots when using \"git diff\", which\n> is not about ranges but about comparing two endpoints.  If we were\n> reinventing Git today from scratch, we would make \"git diff A..B\" an\n> error.  You can consider it a bug that the command accepts a range\n> notation, but this will not change any time soon without a large\n> fight to find and fix uses of the syntax in scripts by longtime Git\n> users have written over the years.\n> \n> Allowing dot-dot on the command line of \"git diff\", instead of\n> diagnosing them as errors and dying, was a stupid mistake we (well,\n> mostly Linus, but I am willing to take the blame too) made due to\n> laziness when we reused the machinery, which we invented to parse\n> the command line of \"log\" family of commands to specify ranges, to\n> parse the command line of \"diff\", which accidentally ended up\n> allowing the syntax for ranges where it shouldn't be allowed.\n> \n> And worse yet, since there was only dot-dot and three-dots came much\n> later, \"git diff A..B\" ended up comparing the endpoints A and B,\n> because there didn't even A...B notation exist.\n> \n> This is not limited to you but any user of modern Git is better off\n> to pretend \"git diff A..B\" does not exist; please unlearn dot-dot\n> and three-dots when using \"git diff\" and you'd be happier.\n\nI agreen that you should not use `A..B`, but what is wrong with\n`A...B`? The alternative is a lot more verbose.\n\ngit diff $(git merge-base A B) B\n\nKevin\n"},{"id":"388832","messageId":"20191223215928.GB38316@google.com","threadId":"52510","inReplyTo":"20191223182939.GB676947@alpha","subject":"Re: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-12-23T21:59:28Z","receivedAt":"2019-12-23T21:59:34Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Kevin Daudt wrote:\n> On Mon, Dec 23, 2019 at 10:02:31AM -0800, Junio C Hamano wrote:\n\n>> Please unlearn dot-dot and three-dots when using \"git diff\", which\n>> is not about ranges but about comparing two endpoints.  If we were\n>> reinventing Git today from scratch, we would make \"git diff A..B\" an\n>> error.  You can consider it a bug that the command accepts a range\n>> notation, but this will not change any time soon without a large\n>> fight to find and fix uses of the syntax in scripts by longtime Git\n>> users have written over the years.\n[...]\n> I agree that you should not use `A..B`, but what is wrong with\n> `A...B`? The alternative is a lot more verbose.\n>\n> git diff $(git merge-base A B) B\n\nCommands like \"git checkout\" have been learning a `...` shorthand\nwhich is not much better as far as intuitiveness goes:\n\n\t# doesn't work, just here for demonstration\n\tgit diff A...B B\n\nWith hindsight, \"git diff A..B\" would be the perfect spelling for\nthis, but that would break too many people's muscle memories and\nscripts.  Would it make sense to have a commandline option for this?\n\n\t# doesn't work, just here for demonstration\n\tgit diff --fork-point A B\n\nA random thought,\nJonathan\n"},{"id":"388834","messageId":"xmqqtv5q66dd.fsf@gitster-ct.c.googlers.com","threadId":"52510","inReplyTo":"20191223182939.GB676947@alpha","subject":"Re: Mismatch meaning between git-diff and git-log for the .. (double dot notation) and ... (triple dot notation)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-23T22:10:06Z","receivedAt":"2019-12-23T22:10:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Daudt <kdaudt@alpinelinux.org> writes:\n\n>> This is not limited to you but any user of modern Git is better off\n>> to pretend \"git diff A..B\" does not exist; please unlearn dot-dot\n>> and three-dots when using \"git diff\" and you'd be happier.\n>\n> I agreen that you should not use `A..B`, but what is wrong with\n> `A...B`? The alternative is a lot more verbose.\n>\n> git diff $(git merge-base A B) B\n\nBecause it would interfere with even grander consistency that we\ncould achieve in the future, if we get rid of it.\n\nWithin the context of \"git diff\" (but not \"git\" in general), \"git\ndiff A...B\" that expands to \"git diff $(git merge-base A B) B\" may\nappear OK, but this thread started by comparing \"git log\" and \"git\ndiff\", so it is no longer worth limiting our vision to a single \"git\ndiff\" command if we want to continue this thread.\n\nSome commands, like \"git checkout A...B\", know that A...B can stand\nfor \"git merge-base A B\" in a context that does not call for a range\nbut calls for a single revision.  We probably would want to teach it\nthe general revision parser machinery so that this can consistently\nbe used.\n\nIn such a world, \"git diff A...B\" ought to mean, because \"diff\" is\nabout discrete endpoints and not about ranges, \"git diff $(git\nmerge-base A B)\", i.e. it should behave just like \"git diff C\" that\ncompares the given single commit and the contents in the working\ntree through the index.  \"git diff A...B\" we currently have by\nmistake should be spelled in \"git diff A...B B\" (or alternatively,\n\"git diff B...A B\").\n\nIt would take a long time and careful transition planninng to reach\nthere, and training people not to use dot-dot notation is merely a\nvery small first step, though.\n\n\n\n"}]}