{"thread":{"id":"31771","subject":"Inconsistency in specifying commit & path for git diff","startedAt":"2012-10-09T19:43:04Z","lastAt":"2012-10-09T21:03:37Z","messageCount":3,"participants":["Arthur Etchells","Andreas Schwab","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"200854","messageId":"50747E48.3060203@gmail.com","threadId":"31771","inReplyTo":null,"subject":"Inconsistency in specifying commit & path for git diff","fromName":"Arthur Etchells","fromEmail":"adetchells@gmail.com","sentAt":"2012-10-09T19:43:04Z","receivedAt":"2012-10-09T19:43:04Z","isPatch":false,"sender":{"key":"adetchells@gmail.com","avatar":null},"body":"git diff <commit>..<commit>\nand\ngit diff <commit> <commit>\nboth succeed\n\nhowever\ngit diff <commit>:<path>..<commit>:<path>\nfails while\ngit diff <commit>:<path> <commit>:<path>\nsucceeds\n\nOS X 10.7.5\ngit version 1.7.9.1\n\nReproduced by another user:\nhttp://stackoverflow.com/questions/12805004/git-cherry-pick-creates-blobs-not-commits#comment17319876_12805004\n\nIt seems logical to support the '..' syntax in both for consistency.\n"},{"id":"200857","messageId":"m2391n8jr5.fsf@igel.home","threadId":"31771","inReplyTo":"50747E48.3060203@gmail.com","subject":"Re: Inconsistency in specifying commit & path for git diff","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-09T20:37:18Z","receivedAt":"2012-10-09T20:37:18Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Arthur Etchells <adetchells@gmail.com> writes:\n\n> git diff <commit>:<path>..<commit>:<path>\n\n<commit>:<path> represents a tree or blob, but .. requires commits as\nits end points.\n\n(You can dereference a commit to get a tree or blob, but not the other\nway round.)\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"200860","messageId":"7vliffe4t2.fsf@alter.siamese.dyndns.org","threadId":"31771","inReplyTo":"50747E48.3060203@gmail.com","subject":"Re: Inconsistency in specifying commit & path for git diff","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-09T21:03:37Z","receivedAt":"2012-10-09T21:03:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arthur Etchells <adetchells@gmail.com> writes:\n\n> git diff <commit>..<commit>\n> and\n> git diff <commit> <commit>\n> both succeed\n> however\n> git diff <commit>:<path>..<commit>:<path>\n> fails while\n> git diff <commit>:<path> <commit>:<path>\n> succeeds\n> ...\n> It seems logical to support the '..' syntax in both for consistency.\n\n\"git diff A..B\" is an illogical thing to say in the first place.  It\nonly happens to work by historical accident, and for that \"it used\nto work like so from the beginning, do not break backward\ncompatibility\" reason, we have kept it working.\n\nBut you are better off unlearning it to keep your sanity when\nlearning git as a new user.\n\nThe dot notation is about a range.  A..B talks about the set of\ncommits that are ancestors of B but not ancestors of A.\n\n    $ git log A..B\n\nmakes perfect sense to show such a range.\n\nBut \"diff\" is about \"comparing two endpoints\".  There is nothing\n\"range\" about such a comparison.  When you compare the state at A\nand at B, you do not even look at anything in between.  That is why\nthe canonical way to say it is\n\n    $ git diff A B\n\nand not\n\n    $ git diff A..B ;# WRONG. DO NOT DO THIS.\n\nAnd <commit>:<path> is a way to name an entity at <path> in the tree\nrecorded in the <commit>.  Typically you name a blob, not a tree\nthat represents a subdirectory, with this syntax.\n\nNow, B1..B2, when B1 and B2 are blobs (or anything that is not\ncommit-ish), does not make sense even as a range, and such a request\nis detected as an error at the syntactic level (i.e. without even\nstarting to \"compare\").\n\n    $ git diff HEAD:Makefile..HEAD~4:Makefile ;# WRONG. DO NOT DO THIS.\n\nIf you want to compare two blobs, you can do so with the canonical\n\"compare two things\" syntax.\n\n    $ git diff HEAD:Makefile HEAD~4:Makefile\n"}]}