{"thread":{"id":"26107","subject":"'show' pretty %B without a diff","startedAt":"2010-12-20T07:38:42Z","lastAt":"2010-12-22T18:41:10Z","messageCount":10,"participants":["Peter Vereshagin","Junio C Hamano","Jakub Narebski","Jonathan Nieder","Martin Langhoff","peter@vereshagin.org"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158388","messageId":"20101220073842.GC10354@external.screwed.box","threadId":"26107","inReplyTo":null,"subject":"'show' pretty %B without a diff","fromName":"Peter Vereshagin","fromEmail":"peter@vereshagin.org","sentAt":"2010-12-20T07:38:42Z","receivedAt":"2010-12-20T07:38:42Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"Hey Mr(s) git show some good to me!\n\nI'd like to output a comment in my script.\nThus, I try: 'git show --format=\"%B\" commitId'\nThere is always diff in the end of the output. No matter what format I specify, even when it is empty.\nHow can I avoid diff output in the 'git show'?\nThank you.\n\n73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)\n--\nhttp://vereshagin.org\n"},{"id":"158393","messageId":"7vmxo0ddbm.fsf@alter.siamese.dyndns.org","threadId":"26107","inReplyTo":"20101220073842.GC10354@external.screwed.box","subject":"Re: 'show' pretty %B without a diff","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-20T09:05:17Z","receivedAt":"2010-12-20T09:05:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Vereshagin <peter@vereshagin.org> writes:\n\n> Hey Mr(s) git show some good to me!\n>\n> I'd like to output a comment in my script.\n> Thus, I try: 'git show --format=\"%B\" commitId'\n> There is always diff in the end of the output. No matter what format I specify, even when it is empty.\n> How can I avoid diff output in the 'git show'?\n\nThe best answer to \"avoid\" it would be not to use \"git show\"; after all\nthe command is about showing the change it introduces when it is used on a\ncommit.\n\nEspecially if you are doing a script, you probably should be using\n\"cat-file commit\" anyway, no?\n"},{"id":"158394","messageId":"20101220111214.GD10354@external.screwed.box","threadId":"26107","inReplyTo":"7vmxo0ddbm.fsf@alter.siamese.dyndns.org","subject":"Re: 'show' pretty %B without a diff","fromName":"Peter Vereshagin","fromEmail":"peter@vereshagin.org","sentAt":"2010-12-20T11:12:15Z","receivedAt":"2010-12-20T11:12:15Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"Hey Mr(s) Junio show some good to me!\n2010/12/20 01:05:17 -0800 Junio C Hamano <gitster@pobox.com> => To Peter Vereshagin :\n\nJCH> > I'd like to output a comment in my script.\nJCH> > Thus, I try: 'git show --format=\"%B\" commitId'\nJCH> > There is always diff in the end of the output. No matter what format I specify, even when it is empty.\nJCH> > How can I avoid diff output in the 'git show'?\nJCH> \nJCH> The best answer to \"avoid\" it would be not to use \"git show\"; after all\nJCH> the command is about showing the change it introduces when it is used on a\nJCH> commit.\nJCH> \nJCH> Especially if you are doing a script, you probably should be using\nJCH> \"cat-file commit\" anyway, no?\n\ncat-file doesn't seem to support formatting option?\nAlso, it outputs 4 more unwanted fields than just the %B... used with the -p is\nthe only what looks like the what I asked. Is it appropriate in a general case\nto skip the everything on that output till the first empty line? cause I'm not\nsure those are always 4 and not-empty lines.\n\nThanks anyway, it's just better than nothing. Although I wish the -p for\ncat-file to behave like the simlar-minded --pretty of the 'show'. (=\n\nOr the Git.pm just to have a functionality to get the %B of the commit.\n\n73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)\n--\nhttp://vereshagin.org\n"},{"id":"158403","messageId":"7v4oa8cobn.fsf@alter.siamese.dyndns.org","threadId":"26107","inReplyTo":"20101220111214.GD10354@external.screwed.box","subject":"Re: 'show' pretty %B without a diff","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-20T18:05:16Z","receivedAt":"2010-12-20T18:05:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Vereshagin <peter@vereshagin.org> writes:\n\n> JCH> Especially if you are doing a script, you probably should be using\n> JCH> \"cat-file commit\" anyway, no?\n>\n> cat-file doesn't seem to support formatting option?\n\nThat is exactly why I suggested \"cat-file\", as you are scripting.  We\nreserve the right to change the human-visible formatting output from\nPorcelain commands like \"show\" any time to make it \"prettier\" (we may\nstart coloring strings that look like object names in the commit log\nmessage in \"git show\" output, for example), while giving scripts more\nstable output through the plumbing commands like \"cat-file\" so that they\ncan parse and process without having to worry about the output format\nchanging under them.\n\nIf your script is _not_ parsing the git command output, but is just\nblindly spewing it out to the invoking user, it is Ok to use \"show\",\nthough.  Check \"-s\" option to the \"show\" command in that case.\n"},{"id":"158430","messageId":"20101221104641.GA8600@external.screwed.box","threadId":"26107","inReplyTo":"7v4oa8cobn.fsf@alter.siamese.dyndns.org","subject":"Re: 'show' pretty %B without a diff","fromName":"Peter Vereshagin","fromEmail":"peter@vereshagin.org","sentAt":"2010-12-21T11:04:47Z","receivedAt":"2010-12-21T11:04:47Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"You know St. Peter won't call my name, Junio!\n2010/12/20 10:05:16 -0800 Junio C Hamano <gitster@pobox.com> => To Peter Vereshagin :\n\nJCH> > JCH> Especially if you are doing a script, you probably should be using\nJCH> > JCH> \"cat-file commit\" anyway, no?\nJCH> >\nJCH> > cat-file doesn't seem to support formatting option?\nJCH> \nJCH> That is exactly why I suggested \"cat-file\", as you are scripting.  We\nJCH> reserve the right to change the human-visible formatting output from\nJCH> Porcelain commands like \"show\" any time to make it \"prettier\" (we may\nJCH> start coloring strings that look like object names in the commit log\nJCH> message in \"git show\" output, for example), while giving scripts more\nJCH> stable output through the plumbing commands like \"cat-file\" so that they\nJCH> can parse and process without having to worry about the output format\nJCH> changing under them.\n\nIMHO there is a difference between coloring the output and digging the data\nfrom the storage, the what is the %B is about for me.\nIn a context of a script I believe every scriptwriter should expect a function\nlike get_comment_raw( $commitId ) than to worry about command output stability.\nThis is just where I believe the Git.pm will get closer to. One day.\nNo matter if such a function should look more like this: $gitObject->newById(\n$commitId )->showDetails( '%B' ); . The I/O operations for this I believe\nshould be the storage files opening and reading, thus the piping from commands\nlike 'cat-file' is only the temporary solution.\nIsn't it?\nFor the applications such an API approach is just more expectable than\nporcelain versus plumbing commands. Although this requires care about features\nlike the particular (e.g., Perl) bindings, it is a must for the applications\nefficiency which is a sense for a modern web at least.\n\nJCH> If your script is _not_ parsing the git command output, but is just\nJCH> blindly spewing it out to the invoking user, it is Ok to use \"show\",\nJCH> though.  Check \"-s\" option to the \"show\" command in that case.\n\n\"show\" command doesn't seem to have \"-s\" switch. Skip it up though ;-)\n\n73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)\n--\nhttp://vereshagin.org\n"},{"id":"158432","messageId":"m38vzjl1yr.fsf@localhost.localdomain","threadId":"26107","inReplyTo":"20101221104641.GA8600@external.screwed.box","subject":"Re: 'show' pretty %B without a diff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-12-21T12:56:30Z","receivedAt":"2010-12-21T12:56:30Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Peter Vereshagin <peter@vereshagin.org> writes:\n> 2010/12/20 10:05:16 -0800 Junio C Hamano <gitster@pobox.com> => To Peter Vereshagin :\n\n> JCH> If your script is _not_ parsing the git command output, but is just\n> JCH> blindly spewing it out to the invoking user, it is Ok to use \"show\",\n> JCH> though.  Check \"-s\" option to the \"show\" command in that case.\n> \n> \"show\" command doesn't seem to have \"-s\" switch. Skip it up though ;-)\n\nHmmm... true, unfortunately it is described in hidden corner: when\ngit-show is used to display commits, it accepts diff family\noptions... including `-s' described in git-diff-tree manpage:\n\n  -s::\n        By default, 'git diff-tree --stdin' shows differences,\n        either in machine-readable form (without '-p') or in patch\n        form (with '-p').  This output can be suppressed.  It is\n        only useful with '-v' flag.\n\n  -v::\n        This flag causes 'git diff-tree --stdin' to also show\n        the commit message before the differences.\n\nI guess that `-s' should be present also in git-show manpage.\n\nThere is also `git log -1` (or `git log -1 --no-walk` for paranoid).\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"158445","messageId":"20101221180459.GA25812@burratino","threadId":"26107","inReplyTo":"m38vzjl1yr.fsf@localhost.localdomain","subject":"Re: 'show' pretty %B without a diff","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-21T18:04:59Z","receivedAt":"2010-12-21T18:04:59Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jakub Narebski wrote:\n\n> I guess that `-s' should be present also in git-show manpage.\n\nIt is mentioned in the examples section since v1.7.3.3~42.  That\nmanpage needs a rework in general, though.\n\n> There is also `git log -1` (or `git log -1 --no-walk` for paranoid).\n\nOr even \"git diff-tree -s --pretty=%B <commit>\" if that is the intent.\n\nAs much as a person might dislike plumbing, plumbing is git's current\nstable API.  Maybe the libgit2 project will come up with something\nbetter[1].  Until then, I am happy to have some commands that avoid\nuser-friendliness niceties (like implied \"HEAD\") that would create\npitfalls when scripting.\n\nMaybe it would be worth adding a plumbing example under the EXAMPLES\nfor each porcelain?  I can see that having to learn a second set of\ncommands might make life hard (like scripting in the bourne shell\nwhen one is a csh user).\n\n[1] I am pessimistic since that project has not made itself very\nvisible for feedback from the git list or submitted changes back to\ngit.  It would be great to be surprised.\n"},{"id":"158455","messageId":"AANLkTi=BJ0NdKrANuXKObNQJbchqdSUhpnttsdU_NnQe@mail.gmail.com","threadId":"26107","inReplyTo":"20101221180459.GA25812@burratino","subject":"Re: 'show' pretty %B without a diff","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2010-12-21T20:27:52Z","receivedAt":"2010-12-21T20:27:52Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Tue, Dec 21, 2010 at 1:04 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Maybe it would be worth adding a plumbing example under the EXAMPLES\n> for each porcelain?\n\nSince porcelain went to C, one thing I often do is checkout really old\nversions of git to see exactly what the shell version of a particular\ncommand did .\n\nThat way, I get a much better understanding of how a certain action is\ndone at the plumbing level; complement that with the documentation for\nreference, and I'm 99% done.\n\nMaybe that helps someone .\n\ncheers,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"158459","messageId":"m3zkrykghj.fsf@localhost.localdomain","threadId":"26107","inReplyTo":"AANLkTi=BJ0NdKrANuXKObNQJbchqdSUhpnttsdU_NnQe@mail.gmail.com","subject":"Re: 'show' pretty %B without a diff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-12-21T20:40:37Z","receivedAt":"2010-12-21T20:40:37Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> On Tue, Dec 21, 2010 at 1:04 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> > Maybe it would be worth adding a plumbing example under the EXAMPLES\n> > for each porcelain?\n> \n> Since porcelain went to C, one thing I often do is checkout really old\n> versions of git to see exactly what the shell version of a particular\n> command did .\n\nYou can always browse 'contrib/examples/' instead.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"158496","messageId":"6e984da6ce5898867d25012ee4250ca9@mx1.skyriver.ru","threadId":"26107","inReplyTo":"20101221180459.GA25812@burratino","subject":"Re: 'show' pretty %B without a diff","fromName":"","fromEmail":"peter@vereshagin.org","sentAt":null,"receivedAt":"2010-12-22T18:41:10Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"On Tue, 21 Dec 2010 12:04:59 -0600, Jonathan Nieder\n<jrnieder@gmail.com> wrote:\n> Or even \"git diff-tree -s --pretty=%B <commit>\" if that is the intent.\n\nExactly the what I asked for. Thanks!\n"}]}