{"thread":{"id":"6000","subject":"Commit-ish shortcut for immediate parent range","startedAt":"2006-10-22T14:48:35Z","lastAt":"2006-10-23T03:33:00Z","messageCount":13,"participants":["Andy Parkins","Jakub Narebski","Linus Torvalds","Jeff King","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"29638","messageId":"200610221548.42048.andyparkins@gmail.com","threadId":"6000","inReplyTo":null,"subject":"Commit-ish shortcut for immediate parent range","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-10-22T14:48:35Z","receivedAt":"2006-10-22T14:48:35Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Hello,\n\nGit's commit-ish is very powerful.  I was wondering however, if there was a \nshortcut for (for example)?\n\n git-diff 3435fdb4c^..3435fdb4c\n\nThat is - the short range of a particular commit's parent to that commit; like\n\n git-diff 3435fdb4c!\n\nOr similar.\n\n\nAndy\n-- \nDr Andrew Parkins, M Eng (Hons), AMIEE\nandyparkins@gmail.com\n"},{"id":"29645","messageId":"ehg1li$mn6$1@sea.gmane.org","threadId":"6000","inReplyTo":"200610221548.42048.andyparkins@gmail.com","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-22T15:11:00Z","receivedAt":"2006-10-22T15:11:00Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Andy Parkins wrote:\n\n> Git's commit-ish is very powerful.  I was wondering however, if there was a \n> shortcut for (for example)?\n> \n>  git-diff 3435fdb4c^..3435fdb4c\n\nThats \"git-diff 3435fdb4c^ 3435fdb4c\" - diff need pair of things\n(one or more might be implied/default), not DAG.\n\n> That is - the short range of a particular commit's parent to that commit; like\n> \n>  git-diff 3435fdb4c!\n> \n> Or similar.\n\nOr similar. You have to use git-diff-tree, not git-diff as git-diff\nuses working tree as second tree if second argument is not given \n(and index as first tree if first argument is not given).\n\n$ git diff-tree -p 3435fdb4c\n\n(-p to show patch instead of \"whatchanged\" output) shows diff to parent\nof commit 3435fdb4c (if commit is merge commit, show nothing; use -m\nor -c or --cc then).\n\n\nBy the way 3435fdb4c.. means 3435fdb4c..HEAD, and ..3435fdb4c means\nHEAD..3435fdb4c (where HEAD means current branch).\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"29650","messageId":"Pine.LNX.4.64.0610221017180.3962@g5.osdl.org","threadId":"6000","inReplyTo":"200610221548.42048.andyparkins@gmail.com","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-22T17:25:23Z","receivedAt":"2006-10-22T17:25:23Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 22 Oct 2006, Andy Parkins wrote:\n> \n> Git's commit-ish is very powerful.  I was wondering however, if there was a \n> shortcut for (for example)?\n> \n>  git-diff 3435fdb4c^..3435fdb4c\n> \n> That is - the short range of a particular commit's parent to that commit; like\n> \n>  git-diff 3435fdb4c!\n\nUmm. That's not actually a very sensible operation. It's only sensible in \nthe special case of \"diff\", and for that special case, what we do is to \nactually just say that the _command_ is special, not the range.\n\nIt's called \"git show\".\n\nSo the thing to do is just\n\n\tgit show 3435fdb4c\n\nand be happy.\n\nAnyway, there's two kinds of commands wrt revision ranges in git:\n\n - \"git diff\"\n - everything else\n\nThat may sound strange, but it's true. \"git diff\" doesn't really do \n\"revision ranges\". It does \"two revision endpoints\", which is literally \nvery different from just about any other git command. All the other \ncommands really think of commits as a \"set of individual commits\" (where \nsometimes the \"set\" is admittedly just a single commit).\n\nSo the reason for you wanting that \"3435fdb4c^..3435fdb4c\" is not that \nit's a particularly useful thing in _general_, it's that \"git diff\" wants \ntwo endpoints, and you want to have that describe a single commit. \n\nHopefully this explains why it's the _command_ that is special, and not \nthe range. The range makes no sense.\n\n\t\t\t\tLinus\n"},{"id":"29653","messageId":"Pine.LNX.4.64.0610221117570.3962@g5.osdl.org","threadId":"6000","inReplyTo":"Pine.LNX.4.64.0610221017180.3962@g5.osdl.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-22T18:25:13Z","receivedAt":"2006-10-22T18:25:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 22 Oct 2006, Linus Torvalds wrote:\n> \n> So the thing to do is just\n> \n> \tgit show 3435fdb4c\n> \n> and be happy.\n\nBtw, if you really _only_ want the diff, you can do either\n\n\tgit-diff-tree -p 3435fdb4c\n\nwhich is the traditional \"core\" command for this. Somewhat sadly, I don't \nthink we have a way to actually turn _off_ the description printing, so \nwhile you can turn off the _diff_ with \"-s\", the best you can do wrt the \ncommit message is probably to use \"--pretty=oneline\" to cut it down to a \nsingle line.\n\nI wonder if we should have a \"--pretty=none\" thing, so that you can use \nthe \"higher-level\" git commands without seeing the log message.\n\nHmm..\n\n\t\t\tLinus\n"},{"id":"29662","messageId":"20061022195315.GB10977@coredump.intra.peff.net","threadId":"6000","inReplyTo":"200610221548.42048.andyparkins@gmail.com","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-10-22T19:53:15Z","receivedAt":"2006-10-22T19:53:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Oct 22, 2006 at 03:48:35PM +0100, Andy Parkins wrote:\n\n> Git's commit-ish is very powerful.  I was wondering however, if there was a \n> shortcut for (for example)?\n> \n>  git-diff 3435fdb4c^..3435fdb4c\n> \n> That is - the short range of a particular commit's parent to that commit; like\n> \n>  git-diff 3435fdb4c!\n> \n> Or similar.\n\nI think a more general (but possibly harder to implement and use!) form\nwould be a commit-ish token for \"refer to previous commit-ish.\" This\nwould not increase expressiveness, but could save a lot of typing. So if\n'!' meant \"the last sha1/ref parsed\", your example range would be:\n\n  3435fdb4c^..!\n\nbut you could also do more exotic things like:\n  3435fdb4c~25..!~20\n\nObviously you could think of more interesting ways to refer to previous\nTHINGS. But I think in most cases in which you have repeated refs, you\nreally are just repeating one ref twice as a basis for a range.\n\nThe '!' character is probably a bad choice, since it's generally an\ninteractive shell metacharacter. I'm not sure what would be a better\nchoice; we're running low on punctuation.\n\nAt any rate, I'm not convinced this is a worthwhile optimization. It's\nannoying to have to re-specify a long sha1, but in 99% of cases, you\nreally are looking for sha1^..sha1. As others have pointed out, that's\nalready handled through git-show.\n\n-Peff\n"},{"id":"29666","messageId":"200610222117.45766.andyparkins@gmail.com","threadId":"6000","inReplyTo":"Pine.LNX.4.64.0610221017180.3962@g5.osdl.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-10-22T20:17:45Z","receivedAt":"2006-10-22T20:17:45Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Sunday 2006, October 22 18:25, Linus Torvalds wrote:\n\n> Umm. That's not actually a very sensible operation. It's only sensible in\n> the special case of \"diff\", and for that special case, what we do is to\n> actually just say that the _command_ is special, not the range.\n>\n> It's called \"git show\".\n\nYou're entirely correct, that that is what I was looking for in that \nparticular case.  However, the reason I raised it as a question was that I \nwas poking around with git (which I'm enjoying immensely by the way - it \nreally is as perfect an SCM as I have ever used) and in short succession did\n\ngit-diff X^..X\ngit-log X^..X\ngit-format-patch X^..X\n\nI imagined that I would eventually stumble on other git commands where I would \nwant to do this operation again.  I'm sure I will have picked an incorrect \ncommand in each case, however, they all did exactly what I wanted so I \nstopped looking for the \"right\" command :-)\n\n\nAndy\n\n-- \nDr Andrew Parkins, M Eng (Hons), AMIEE\nandyparkins@gmail.com\n"},{"id":"29673","messageId":"Pine.LNX.4.63.0610222254210.14200@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6000","inReplyTo":"Pine.LNX.4.64.0610221017180.3962@g5.osdl.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-22T20:55:55Z","receivedAt":"2006-10-22T20:55:55Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 22 Oct 2006, Linus Torvalds wrote:\n\n> Anyway, there's two kinds of commands wrt revision ranges in git:\n> \n>  - \"git diff\"\n>  - everything else\n\nWell, there is also \"git format-patch\". If you provide it with only one \ncommit-ish \"<rev>\", it will believe you actually meant \"<rev>..\".\n\nCiao,\nDscho\n"},{"id":"29674","messageId":"Pine.LNX.4.64.0610221331571.3962@g5.osdl.org","threadId":"6000","inReplyTo":"200610222117.45766.andyparkins@gmail.com","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-22T20:56:29Z","receivedAt":"2006-10-22T20:56:29Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 22 Oct 2006, Andy Parkins wrote:\n> \n> You're entirely correct, that that is what I was looking for in that \n> particular case.  However, the reason I raised it as a question was that I \n> was poking around with git (which I'm enjoying immensely by the way - it \n> really is as perfect an SCM as I have ever used) and in short succession did\n> \n> git-diff X^..X\n> git-log X^..X\n> git-format-patch X^..X\n\nNow, \"git show\" obviously does exactly what you probably wanted, but for \nfuture reference, the \"git log\" family of commands also take a \"number of \ncommits\" limiter.\n\nSo you can also do things like\n\n\tgit log --cc -1 X\n\nand it will actually do something very similar to \"git show\". It's not \n_quite_ identical, but it's close - at least for the special case of a \nsingle commit.\n\n\"git show\" actually uses a magic \"no_walk\" internal flag which means that \nyou can give it _several_ revisions, and it will take them as a raw \"list\" \nof revisions rather than take them as a command to \"walk\" the revision \nspace and then just show one of them (like the \"git log --cc -1\" example \nwould do).\n\nSo with \"git show\", you can do\n\n\tgit show X Y Z\n\nand it will show those exact three commits. That's _different_ from\n\n\tgit log --cc -3 X Y Z\n\nwhich will show the three \"most recent\" commits when you start walking the \nrevision DAG. (The above \"git log\" command really doesn't make much sense, \nsince the output will depend on commit date - it has well-specified \nbehaviour, but it's really a pretty random thing to do: it might, for \nexample, show the three commits X, X^ and Z, and not Y at all).\n\nAnyway, \"git show\" is a very useful thing. It's actually one of the \ncommands I use most. If I ever want to see what happened in a single \ncommit (eg somebody sends me a bug-report and says \"commit XYZ introduced \na regression\"), that's what I would use.\n\nLooking at my history, the commands I tend to use most are:\n\n\tgit log\n\tgit diff\n\tgit pull <some-remote-repo>\n\tgitk ORIG_HEAD..\n\tgit log -p some/directory/or/file\n\tgit grep -w <some-identifier> [possibly-some-subdirectory]\n\tgit show <some-rev>\n\nand while I think that \"git pull\" and \"gitk ORIG_HEAD..\" thing tends to be \nsomething special to being a top-level maintainer (although maybe I'm \nwrong - you'd probably do the same just because you're following a remote \ntree under active development), all the rest are commands that everybody \nshould know so intimately that they don't even need to think about them.\n\n\"git grep\" in particular seems to be something that a lot of people \nhaven't necessarily even realized is there. Yet it's actually extremely \npowerful and efficient both for the \"current tree\" and for \"old \nrevisions\". \n\nIt's interesting: I used to do a lot of \"plain grep\" usage, but with git, \nmost of my greps by far are all of the form \"git grep\". I've gotten so \nused to it that I find myself wanting to do \"git grep\" even on non-git \nstuff, and if I look at somebody elses tar-ball I often end up doing\n\n\tgit init-db\n\tgit add .\n\njust to be able to do \"git grep\" on it. I've totally stopped doing the \n\"find . -name '*.[ch]' | xargs grep -w\" sequence that I _used_ to do a lot \nof.\n\n\t\t\tLinus\n"},{"id":"29679","messageId":"ehgoii$1ap$1@sea.gmane.org","threadId":"6000","inReplyTo":"Pine.LNX.4.64.0610221331571.3962@g5.osdl.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-22T21:41:57Z","receivedAt":"2006-10-22T21:41:57Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> Now, \"git show\" obviously does exactly what you probably wanted, but for \n> future reference, the \"git log\" family of commands also take a \"number of \n> commits\" limiter.\n> \n> So you can also do things like\n> \n>         git log --cc -1 X\n> \n> and it will actually do something very similar to \"git show\". It's not \n> _quite_ identical, but it's close - at least for the special case of a \n> single commit.\n\nAnd of course this shortcut is not documented. git-log(1) and\ngit-rev-list(1) talks only about \"--max-count=<n>\", and \"-n <n>\",\nand doesn't talk about possible shortcuts \"-n<n>\" and \"-<n>\".\nPerhaps because those shortcuts are discouraged?\n\nAdditionally you can find \"-n <n>\" shortcut only further on\nthe git-rev-list(1).\n\n\nPatch will follow.\n\nBTW. what does \"recursive diff\" mean (in git)?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"29680","messageId":"Pine.LNX.4.63.0610230008490.14200@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6000","inReplyTo":"ehgoii$1ap$1@sea.gmane.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-22T22:09:21Z","receivedAt":"2006-10-22T22:09:21Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 22 Oct 2006, Jakub Narebski wrote:\n\n> BTW. what does \"recursive diff\" mean (in git)?\n\nAFAIU it means that the diff code recurses into subdirectories.\n\nCiao,\nDscho\n"},{"id":"29681","messageId":"ehgrj9$8u9$1@sea.gmane.org","threadId":"6000","inReplyTo":"Pine.LNX.4.63.0610230008490.14200@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-22T22:33:33Z","receivedAt":"2006-10-22T22:33:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Schindelin wrote:\n\n> On Sun, 22 Oct 2006, Jakub Narebski wrote:\n> \n>> BTW. what does \"recursive diff\" mean (in git)?\n> \n> AFAIU it means that the diff code recurses into subdirectories.\n\nWhen git-diff _doesn't_ recurse into subdirectories?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"29689","messageId":"7v8xj72a9k.fsf@assigned-by-dhcp.cox.net","threadId":"6000","inReplyTo":"ehgrj9$8u9$1@sea.gmane.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-22T23:36:39Z","receivedAt":"2006-10-22T23:36:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Johannes Schindelin wrote:\n>\n>> On Sun, 22 Oct 2006, Jakub Narebski wrote:\n>> \n>>> BTW. what does \"recursive diff\" mean (in git)?\n>> \n>> AFAIU it means that the diff code recurses into subdirectories.\n>\n> When git-diff _doesn't_ recurse into subdirectories?\n\nWhen it is not told to.\n\nThe Porcelainish commands (git-diff, git-show) default to\nrecursive, but low-level commands don't.\n\nCompare these three:\n\n\tgit diff --raw v1.4.3.1^^^..v1.4.3.1^^\n\tgit diff-tree v1.4.3.1^^^..v1.4.3.1^^\n\tgit diff-tree -r v1.4.3.1^^^..v1.4.3.1^^\n"},{"id":"29697","messageId":"Pine.LNX.4.64.0610222029390.3962@g5.osdl.org","threadId":"6000","inReplyTo":"ehgoii$1ap$1@sea.gmane.org","subject":"Re: Commit-ish shortcut for immediate parent range","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-23T03:33:00Z","receivedAt":"2006-10-23T03:33:00Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 22 Oct 2006, Jakub Narebski wrote:\n> \n> BTW. what does \"recursive diff\" mean (in git)?\n\nFor projects with subdirectories (and git itself has almost none), the \ndefault \"raw, nonrecursive\" diff looks something like this:\n\n\tf8829caee311207afbc882794bdc5aa0db5caf33\n\t:040000 040000 db7ae247da2ede4d0f932b86771424534d2960b8 9033be5eb62db6fd778793f9f51e28734bb3d9f8 M      arch\n\t:040000 040000 c96e5293819986ae7c13a8ef779c5f2066b9575f 5950afceabd99053964778b49df19ba794a21b75 M      include\n\nwhile the same commit with \"raw, recursive\" looks like\n\n\tf8829caee311207afbc882794bdc5aa0db5caf33\n\t:100644 100644 88b72c9a84957f2ac787ccf83fa46c4dbb0818d2 2de4d3c367a2c2da9adb6bcf29b5105c46c01f78 M      arch/mips/mm/init.c\n\t:100644 100644 4bdaa05f485b446e0d66587015cbd8378abf4a69 4a61e624b0ecfcd921a560d426e92e1df2df1de2 M      arch/mips/mm/pgtable-32.c\n\t:100644 100644 44b5e97fff65f75286fdd15f33c2bcf40841082a 8d600d307d5ddb3f617ffc34929ea98d4613b4a7 M      arch/mips/mm/pgtable-64.c\n\t:100644 100644 9ab59e2bb23368530fa67c95af0d6ab2c4f7fe8f e3c9925876a3ce4eb80ec67937362cd7d014ad2f M      include/asm-mips/cacheflush.h\n\t:100644 100644 6959bdb59310b096ec7797e0a31c78fde5aa9afc 02c8a13fc894838b27336ae42fbb542f87132e01 M      include/asm-mips/fixmap.h\n\nie the \"recursive\" diff will recurse into subdirectories.\n\nA _patch_ is always recursive (you cannot make a patch-like diff for just \nthe \"tree entry\", only for actual blobs), so you can only see this \ndifference for raw git SHA1 diffs.\n\n\t\tLinus\n"}]}