{"thread":{"id":"20148","subject":"[PATCH 0/2] cosmetic improvements for \"git show tag\"","startedAt":"2009-07-17T23:16:22Z","lastAt":"2009-07-19T18:05:16Z","messageCount":9,"participants":["Jeff King","Nicolas Sebrecht","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"118206","messageId":"20090717231622.GA13511@coredump.intra.peff.net","threadId":"20148","inReplyTo":null,"subject":"[PATCH 0/2] cosmetic improvements for \"git show tag\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-17T23:16:22Z","receivedAt":"2009-07-17T23:16:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Right now, if you do:\n\n  $ git tag -m 'annotated tag message' foo\n  $ git show foo\n\nyou get:\n\n    tag foo\n    Tagger: Jeff King <peff@peff.net>\n    Date:   Fri Jul 17 19:10:54 2009 -0400\n\n\n    annotated tag message\n    commit 88c17f18d7f3091508218b36a17cdf0dfd56ae65\n    Author: Jeff King <peff@peff.net>\n    Date:   Fri Jul 17 19:10:50 2009 -0400\n\n        commit message\n\n    diff ...\n\nwhich is IMHO quite hard to read. These two one-liner patches improve\nthe output to:\n\n    tag foo\n    Tagger: Jeff King <peff@peff.net>\n    Date:   Fri Jul 17 19:10:54 2009 -0400\n\n    annotated tag message\n\n    commit 88c17f18d7f3091508218b36a17cdf0dfd56ae65\n    Author: Jeff King <peff@peff.net>\n    Date:   Fri Jul 17 19:10:50 2009 -0400\n\n        commit message\n\n    diff ...\n\nwhich I find much more readable. The changes are localized to \"git\nshow\", and since it is porcelain, I don't think there should be any\nnegative fallout by changing the output.\n\n---\nJeff King (2):\n  show: suppress extra newline when showing annotated tag\n  show: add space between tag body and tagged object\n\n builtin-log.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n"},{"id":"118207","messageId":"20090717231834.GA13624@coredump.intra.peff.net","threadId":"20148","inReplyTo":"20090717231622.GA13511@coredump.intra.peff.net","subject":"[PATCH 1/2] show: suppress extra newline when showing annotated tag","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-17T23:18:34Z","receivedAt":"2009-07-17T23:18:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When showing a tag, our header parsing finishes with the\noffset pointing to the newline separating the tag header\nfrom the tag body. This means that the printed body will\nalways start with a newline.\n\nHowever, we also add an extra newline when printing the\ntagger information. This leads to an ugly double-newline:\n\n    $ git show v1.6.3\n    tag v1.6.3\n    Tagger: Junio C Hamano <gitster@pobox.com>\n    Date:   Wed May 6 18:16:47 2009 -0700\n\n    GIT 1.6.3\n    -----BEGIN PGP SIGNATURE-----\n    ...\n\nThis patch removes the extra newline from the end of the\ntagger headers. This is a better solution than suppressing\nthe separator newline, because it retains the behavior for\ntags which have no tagger. E.g., \"git show v0.99\" will\ncontinue to look like:\n\n      $ git show v0.99\n      tag v0.99\n\n      Test-release for wider distribution.\n      ...\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI tried to consider the output for real-world cases. In theory, you\ncould have a corrupted tag with not only no body, but no newline\nseparator. Then it would display as:\n\n  tag foo\n  commit ...\n\nwith no extra newline. But since nothing should be generating such a\ntag, I don't think it is a problem.\n\n builtin-log.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 0c2fa0a..b05796d 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -257,7 +257,7 @@ static void show_tagger(char *buf, int len, struct rev_info *rev)\n \tpp_user_info(\"Tagger\", rev->commit_format, &out, buf, rev->date_mode,\n \t\tgit_log_output_encoding ?\n \t\tgit_log_output_encoding: git_commit_encoding);\n-\tprintf(\"%s\\n\", out.buf);\n+\tprintf(\"%s\", out.buf);\n \tstrbuf_release(&out);\n }\n \n-- \n1.6.4.rc1.174.g317bf.dirty\n"},{"id":"118208","messageId":"20090717232227.GB13624@coredump.intra.peff.net","threadId":"20148","inReplyTo":"20090717231622.GA13511@coredump.intra.peff.net","subject":"[PATCH 2/2] show: add space between tag body and tagged object","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-17T23:22:28Z","receivedAt":"2009-07-17T23:22:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When showing an annotated tag, \"git show\" will always\ndisplay the pointed-to object. However, it didn't separate\nthe two with whitespace, making it more difficult to notice\nwhere the new object started. For example:\n\n  $ git tag -m 'my message' foo\n  $ git show foo\n  tag foo\n  Tagger: Jeff King <peff@peff.net>\n  Date:   Fri Jul 17 18:46:25 2009 -0400\n\n  my message\n  commit 41cabf8fed2694ba33e01d64f9094f2fc5e5805a\n  Author: Jeff King <peff@peff.net>\n  Date:   Thu Jul 16 17:31:34 2009 -0400\n  ...\n\nThis patch adds a blank line between \"my message\" and\n\"commit 41c...\", making it easier to read.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI was tempted to add logic for \"put a blank line separator between each\ntwo items printed by git show\", instead of just tags. But:\n\n  - commits already do that (e.g., \"git show HEAD HEAD^\" looks fine)\n\n  - blobs don't do it, but you probably don't want them to. I don't know\n    why you would really do \"git show HEAD:foo HEAD:bar\", but you could,\n    and I would expect it to concatenate them without extra data.\n\nTrees don't do it, so if you \"git show HEAD^{tree} HEAD^{tree}\" there is\nno separator. Maybe that is worth fixing separately, but I find it\nunlikely for somebody to do that. Annotated tags are the much more\ncommon case, because you always get two objects displayed.\n\n builtin-log.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex b05796d..d3e4d1a 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -342,6 +342,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t    sha1_to_hex(t->tagged->sha1));\n \t\t\tobjects[i].item = o;\n \t\t\ti--;\n+\t\t\tputchar('\\n');\n \t\t\tbreak;\n \t\t}\n \t\tcase OBJ_TREE:\n-- \n1.6.4.rc1.174.g317bf.dirty\n"},{"id":"118211","messageId":"20090718011006.GB12968@vidovic","threadId":"20148","inReplyTo":"20090717231622.GA13511@coredump.intra.peff.net","subject":"[PATCH 0/2] Re: cosmetic improvements for \"git show tag\"","fromName":"Nicolas Sebrecht","fromEmail":"nicolas.s.dev@gmx.fr","sentAt":"2009-07-18T01:10:06Z","receivedAt":"2009-07-18T01:10:06Z","isPatch":true,"sender":{"key":"nicolas.s.dev@gmx.fr","avatar":null},"body":"The 17/07/09, Jeff King wrote:\n\n>                                   These two one-liner patches improve\n> the output to:\n> \n>     tag foo\n>     Tagger: Jeff King <peff@peff.net>\n>     Date:   Fri Jul 17 19:10:54 2009 -0400\n> \n>     annotated tag message\n> \n>     commit 88c17f18d7f3091508218b36a17cdf0dfd56ae65\n>     Author: Jeff King <peff@peff.net>\n>     Date:   Fri Jul 17 19:10:50 2009 -0400\n> \n>         commit message\n> \n>     diff ...\n> \n> which I find much more readable. \n\nNice. What about adding an extra newline between tags?\n\n  $ git tag v1.6.1 v1.6.2\n\n\t<snip>\n\n  +  link:RelNotes-1.6.1.txt[1.6.1].\n  +\n   * link:v1.6.0.6/git.html[documentation for release 1.6.0.6]\n   \n   * release notes for\n  tag v1.6.2\n  Tagger: Junio C Hamano <gitster@pobox.com>\n  Date:   Tue Mar 3 23:37:25 2009 -0800\n\n  <snip>\n\nIOW, between \" * release notes for\" and \"tag v1.6.2\" here.\n\n-- \nNicolas Sebrecht\n"},{"id":"118212","messageId":"20090718014743.GA16381@coredump.intra.peff.net","threadId":"20148","inReplyTo":"20090718011006.GB12968@vidovic","subject":"Re: [PATCH 0/2] Re: cosmetic improvements for \"git show tag\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-18T01:47:43Z","receivedAt":"2009-07-18T01:47:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jul 18, 2009 at 03:10:06AM +0200, Nicolas Sebrecht wrote:\n\n> Nice. What about adding an extra newline between tags?\n> \n>   $ git tag v1.6.1 v1.6.2\n> \n> \t<snip>\n> \n>   +  link:RelNotes-1.6.1.txt[1.6.1].\n>   +\n>    * link:v1.6.0.6/git.html[documentation for release 1.6.0.6]\n>    \n>    * release notes for\n>   tag v1.6.2\n>   Tagger: Junio C Hamano <gitster@pobox.com>\n>   Date:   Tue Mar 3 23:37:25 2009 -0800\n> \n>   <snip>\n> \n> IOW, between \" * release notes for\" and \"tag v1.6.2\" here.\n\nHmph. I thought that should just work, because of the newline after the\ncommit. But it seems that you only get that if the next thing is a\ncommit. Hrm.. and it is even worse. The code to print that newline comes\nfrom printing the second commit, which says \"oh, we've already printed a\ncommit\" and adds the newline.\n\nSo when you show two tags you get:\n\n  tag foo\n\n  message\n\n  commit foo^{}\n\n  message\n  tag bar\n\n\n  commit bar^{}\n\nThat is, the newline is actually stuck in the wrong place. So we\nactually need to turn that newline off, which I'm not sure is possible.\nI'll look into it more.\n\n-Peff\n"},{"id":"118217","messageId":"20090718032527.GA16708@vidovic","threadId":"20148","inReplyTo":"20090717231834.GA13624@coredump.intra.peff.net","subject":"[PATCH 1/2] Re: show: suppress extra newline when showing annotated tag","fromName":"Nicolas Sebrecht","fromEmail":"nicolas.s.dev@gmx.fr","sentAt":"2009-07-18T03:25:27Z","receivedAt":"2009-07-18T03:25:27Z","isPatch":true,"sender":{"key":"nicolas.s.dev@gmx.fr","avatar":null},"body":"The 17/07/09, Jeff King wrote:\n\n> However, we also add an extra newline when printing the\n> tagger information. This leads to an ugly double-newline:\n\nI can't see the double-newline.\n\n>     $ git show v1.6.3\n>     tag v1.6.3\n>     Tagger: Junio C Hamano <gitster@pobox.com>\n>     Date:   Wed May 6 18:16:47 2009 -0700\n> \n>     GIT 1.6.3\n>     -----BEGIN PGP SIGNATURE-----\n>     ...\n\nI guess you meant:\n\n     $ git show v1.6.3\n     tag v1.6.3\n     Tagger: Junio C Hamano <gitster@pobox.com>\n     Date:   Wed May 6 18:16:47 2009 -0700\n\n \n     GIT 1.6.3\n     -----BEGIN PGP SIGNATURE-----\n     ...\n\n-- \nNicolas Sebrecht\n"},{"id":"118218","messageId":"20090718034710.GA18873@coredump.intra.peff.net","threadId":"20148","inReplyTo":"20090718032527.GA16708@vidovic","subject":"Re: [PATCH 1/2] Re: show: suppress extra newline when showing annotated tag","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-18T03:47:10Z","receivedAt":"2009-07-18T03:47:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jul 18, 2009 at 05:25:27AM +0200, Nicolas Sebrecht wrote:\n\n> I can't see the double-newline.\n> [...]\n> I guess you meant:\n> \n>      $ git show v1.6.3\n>      tag v1.6.3\n>      Tagger: Junio C Hamano <gitster@pobox.com>\n>      Date:   Wed May 6 18:16:47 2009 -0700\n> \n>  \n>      GIT 1.6.3\n>      -----BEGIN PGP SIGNATURE-----\n>      ...\n\nUrgh, sorry, yes. I accidentally cut-and-pasted from the _fixed_\nversion. :)\n\n-Peff\n"},{"id":"118224","messageId":"20090718101436.GA22535@coredump.intra.peff.net","threadId":"20148","inReplyTo":"20090718014743.GA16381@coredump.intra.peff.net","subject":"Re: [PATCH 0/2] Re: cosmetic improvements for \"git show tag\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-18T10:14:37Z","receivedAt":"2009-07-18T10:14:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 17, 2009 at 09:47:43PM -0400, Jeff King wrote:\n\n> So when you show two tags you get:\n> \n>   tag foo\n> \n>   message\n> \n>   commit foo^{}\n> \n>   message\n>   tag bar\n> \n> \n>   commit bar^{}\n> \n> That is, the newline is actually stuck in the wrong place. So we\n> actually need to turn that newline off, which I'm not sure is possible.\n> I'll look into it more.\n\nThe code calls into log_tree_commit, which uses the \"shown_one\" member\nof rev_info to determine. So we should be able to just use that for our\ntags, and everything will work fine.\n\nI think we can replace 2/2 with the patch below, which also covers the\ntree case neatly.\n\n-- >8 --\nSubject: [PATCH] show: add space between multiple items\n\nWhen showing an annotated tag, \"git show\" will always\ndisplay the pointed-to object. However, it didn't separate\nthe two with whitespace, making it more difficult to notice\nwhere the new object started. For example:\n\n  $ git tag -m 'my message' foo\n  $ git show foo\n  tag foo\n  Tagger: Jeff King <peff@peff.net>\n  Date:   Fri Jul 17 18:46:25 2009 -0400\n\n  my message\n  commit 41cabf8fed2694ba33e01d64f9094f2fc5e5805a\n  Author: Jeff King <peff@peff.net>\n  Date:   Thu Jul 16 17:31:34 2009 -0400\n  ...\n\nThis patch respects and sets the rev.shown_one member to\nprepend a blank line before showing a second item. We use\nthis member of rev_info instead of a local flag, because the\nlog_tree_commit we call into for showing commits already\nrespects and sets that flag. Meaning that everything will be\nspaced properly if you intermix commits and tags, like:\n\n  $ git show v1.6.3 v1.6.2 HEAD\n\nIn that case, a single blank line will separate the first\ntag, the commit it points to, the second tag, the commit\nthat one points to, and the final commit.\n\nWhile we're at it, let's also support trees, so that even\nsomething as crazy as\n\n  $ git show HEAD^{tree} HEAD~1^{tree} HEAD\n\nwill also be spaced in an easy-to-read way. However, we\nintentionally do _not_ insert blank lines for blobs, so\nthat specifying multiple blobs gives a strict concatenation.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-log.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex b05796d..3035816 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -329,11 +329,14 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\tcase OBJ_TAG: {\n \t\t\tstruct tag *t = (struct tag *)o;\n \n+\t\t\tif (rev.shown_one)\n+\t\t\t\tputchar('\\n');\n \t\t\tprintf(\"%stag %s%s\\n\",\n \t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tt->tag,\n \t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tret = show_object(o->sha1, 1, &rev);\n+\t\t\trev.shown_one = 1;\n \t\t\tif (ret)\n \t\t\t\tbreak;\n \t\t\to = parse_object(t->tagged->sha1);\n@@ -345,12 +348,15 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\tbreak;\n \t\t}\n \t\tcase OBJ_TREE:\n+\t\t\tif (rev.shown_one)\n+\t\t\t\tputchar('\\n');\n \t\t\tprintf(\"%stree %s%s\\n\\n\",\n \t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tname,\n \t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tread_tree_recursive((struct tree *)o, \"\", 0, 0, NULL,\n \t\t\t\t\tshow_tree_object, NULL);\n+\t\t\trev.shown_one = 1;\n \t\t\tbreak;\n \t\tcase OBJ_COMMIT:\n \t\t\trev.pending.nr = rev.pending.alloc = 0;\n-- \n1.6.4.rc1.177.g80fb1.dirty\n"},{"id":"118269","messageId":"7v7hy4y2eb.fsf@alter.siamese.dyndns.org","threadId":"20148","inReplyTo":"20090718101436.GA22535@coredump.intra.peff.net","subject":"Re: [PATCH 0/2] Re: cosmetic improvements for \"git show tag\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-07-19T18:05:16Z","receivedAt":"2009-07-19T18:05:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> The code calls into log_tree_commit, which uses the \"shown_one\" member\n> of rev_info to determine. So we should be able to just use that for our\n> tags, and everything will work fine.\n>\n> I think we can replace 2/2 with the patch below, which also covers the\n> tree case neatly.\n\nAck.  Looks sane.\n\nThanks.\n"}]}