{"thread":{"id":"9958","subject":"[PATCH] Added a new placeholder '%cm' for full commit message","startedAt":"2007-09-21T10:14:20Z","lastAt":"2007-09-25T12:46:47Z","messageCount":12,"participants":["Michal Vitecek","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53710","messageId":"20070921101420.GD22869@mageo.cz","threadId":"9958","inReplyTo":null,"subject":"[PATCH] Added a new placeholder '%cm' for full commit message","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-21T10:14:20Z","receivedAt":"2007-09-21T10:14:20Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":" Hello,\n\n I have added a new placeholder '%cm' for a full commit message. I made\n it because I want to use my own pretty format which currently only\n allows '%s' for subject and '%b' for body. But '%b' is substituted with\n <undefined> if the body is \"missing\" which I obviously don't like :)\n\n Thanks for consideration,\n                        Michal\n-- \n\t\tfuf\t\t(fuf@mageo.cz)\n\n\n>From 5e22a989e6805d860b8477393fa8a6cc54f35193 Mon Sep 17 00:00:00 2001\nFrom: Michal Vitecek <fuf@mageo.cz>\nDate: Fri, 21 Sep 2007 12:02:57 +0200\nSubject: [PATCH] Added a new placeholder '%cm' for full commit message\n\n---\n Documentation/pretty-formats.txt |    1 +\n commit.c                         |   18 +++++++++++++++++-\n 2 files changed, 18 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 0193c3c..26c42d3 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -117,6 +117,7 @@ The placeholders are:\n - '%e': encoding\n - '%s': subject\n - '%b': body\n+- '%cm': commit message\n - '%Cred': switch color to red\n - '%Cgreen': switch color to green\n - '%Cblue': switch color to blue\ndiff --git a/commit.c b/commit.c\nindex 99f65ce..1e24e21 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -814,6 +814,7 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t\t{ \"%e\" },\t/* encoding */\n \t\t{ \"%s\" },\t/* subject */\n \t\t{ \"%b\" },\t/* body */\n+                { \"%cm\" },      /* commit message (subject and body) */\n \t\t{ \"%Cred\" },\t/* red */\n \t\t{ \"%Cgreen\" },\t/* green */\n \t\t{ \"%Cblue\" },\t/* blue */\n@@ -835,12 +836,14 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t\tIENCODING,\n \t\tISUBJECT,\n \t\tIBODY,\n+                ICOMMIT_MESSAGE,\n \t\tIRED, IGREEN, IBLUE, IRESET_COLOR,\n \t\tINEWLINE,\n \t\tILEFT_RIGHT,\n \t};\n \tstruct commit_list *p;\n \tchar parents[1024];\n+        int cm_len = 0;\n \tint i;\n \tenum { HEADER, SUBJECT, BODY } state;\n \tconst char *msg = commit->buffer;\n@@ -897,6 +900,7 @@ long format_commit_message(const struct commit *commit, const void *format,\n \n \t\tif (state == SUBJECT) {\n \t\t\ttable[ISUBJECT].value = xstrndup(msg + i, eol - i);\n+                        cm_len = eol - i + 2; /* + 2 for 2 newlines */\n \t\t\ti = eol;\n \t\t}\n \t\tif (i == eol) {\n@@ -915,8 +919,20 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t\t\t\txstrndup(msg + i + 9, eol - i - 9);\n \t\ti = eol;\n \t}\n-\tif (msg[i])\n+\tif (msg[i]) {\n \t\ttable[IBODY].value = xstrdup(msg + i);\n+                cm_len += strlen(msg + i);\n+        }\n+        if (cm_len) {\n+            table[ICOMMIT_MESSAGE].value = xmalloc(cm_len + 1);\n+            table[ICOMMIT_MESSAGE].value[0] = '\\0';\n+            if (table[ISUBJECT].value) {\n+                strcpy(table[ICOMMIT_MESSAGE].value, table[ISUBJECT].value);\n+                strcat(table[ICOMMIT_MESSAGE].value, \"\\n\\n\");\n+            }\n+            if (table[IBODY].value)\n+                strcat(table[ICOMMIT_MESSAGE].value, table[IBODY].value);\n+        }\n \tfor (i = 0; i < ARRAY_SIZE(table); i++)\n \t\tif (!table[i].value)\n \t\t\tinterp_set_entry(table, i, \"<unknown>\");\n-- \n1.5.3.1\n\n"},{"id":"53711","messageId":"Pine.LNX.4.64.0709211146090.28395@racer.site","threadId":"9958","inReplyTo":"20070921101420.GD22869@mageo.cz","subject":"Re: [PATCH] Added a new placeholder '%cm' for full commit message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-21T10:47:19Z","receivedAt":"2007-09-21T10:47:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 21 Sep 2007, Michal Vitecek wrote:\n\n> I have added a new placeholder '%cm' for a full commit message.\n\nYou mean the raw message, including the headers?  Why not use \"%r\" for \nthat?\n\n> I made it because I want to use my own pretty format which currently \n> only allows '%s' for subject and '%b' for body. But '%b' is substituted \n> with <undefined> if the body is \"missing\" which I obviously don't like \n> :)\n\nThen you should fix %b not to show \"<undefined>\".\n\nAnd please adher to the tips in Documentation/SubmittingPatches.\n\nThank you,\nDscho\n"},{"id":"53713","messageId":"20070921110646.GA9072@mageo.cz","threadId":"9958","inReplyTo":"Pine.LNX.4.64.0709211146090.28395@racer.site","subject":"Re: [PATCH] Added a new placeholder '%cm' for full commit message","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-21T11:06:46Z","receivedAt":"2007-09-21T11:06:46Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":"Johannes Schindelin wrote:\n>On Fri, 21 Sep 2007, Michal Vitecek wrote:\n>\n>> I have added a new placeholder '%cm' for a full commit message.\n>\n>You mean the raw message, including the headers?  Why not use \"%r\" for \n>that?\n\n No, sorry for the incorrect term. I meant the whole commit message\n (subject + 2*\\n + body).\n\n>> I made it because I want to use my own pretty format which currently \n>> only allows '%s' for subject and '%b' for body. But '%b' is substituted \n>> with <undefined> if the body is \"missing\" which I obviously don't like \n>> :)\n>\n>Then you should fix %b not to show \"<undefined>\".\n\n I'll do it if it is okay. Shall I do the same for the other\n placeholders as well?\n\n>And please adher to the tips in Documentation/SubmittingPatches.\n\n Will do, sorry about the attachment - still learning :)\n\n    Thank you,\n                Michal\n-- \n\t\tfuf\t\t(fuf@mageo.cz)\n"},{"id":"53714","messageId":"Pine.LNX.4.64.0709211207070.28395@racer.site","threadId":"9958","inReplyTo":"20070921110646.GA9072@mageo.cz","subject":"Re: [PATCH] Added a new placeholder '%cm' for full commit message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-21T11:08:35Z","receivedAt":"2007-09-21T11:08:35Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 21 Sep 2007, Michal Vitecek wrote:\n\n> Johannes Schindelin wrote:\n> >On Fri, 21 Sep 2007, Michal Vitecek wrote:\n> >\n> >> I have added a new placeholder '%cm' for a full commit message.\n> >\n> >You mean the raw message, including the headers?  Why not use \"%r\" for \n> >that?\n> \n>  No, sorry for the incorrect term. I meant the whole commit message\n>  (subject + 2*\\n + body).\n\nAh, makes sense.  In that case, \"%M\" maybe?\n\n> >> I made it because I want to use my own pretty format which currently \n> >> only allows '%s' for subject and '%b' for body. But '%b' is \n> >> substituted with <undefined> if the body is \"missing\" which I \n> >> obviously don't like :)\n> >\n> >Then you should fix %b not to show \"<undefined>\".\n> \n>  I'll do it if it is okay. Shall I do the same for the other\n>  placeholders as well?\n\nYeah.  Don't know why I did it that way.\n\n> >And please adher to the tips in Documentation/SubmittingPatches.\n> \n>  Will do, sorry about the attachment - still learning :)\n\nNo problem.  Thanks for contributing!\n\nCiao,\nDscho\n"},{"id":"53725","messageId":"20070921140500.GB9072@mageo.cz","threadId":"9958","inReplyTo":"Pine.LNX.4.64.0709211207070.28395@racer.site","subject":"[PATCH] Use \"\" instead of \"<unknown>\" for placeholders [was Re: [PATCH] Added a new placeholder '%cm' for full commit message]","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-21T14:05:00Z","receivedAt":"2007-09-21T14:05:00Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":"Johannes Schindelin wrote:\n>On Fri, 21 Sep 2007, Michal Vitecek wrote:\n>> Johannes Schindelin wrote:\n>> >On Fri, 21 Sep 2007, Michal Vitecek wrote:\n>> >\n>> >> I have added a new placeholder '%cm' for a full commit message.\n>> >\n>> >You mean the raw message, including the headers?  Why not use \"%r\" for \n>> >that?\n>> \n>>  No, sorry for the incorrect term. I meant the whole commit message\n>>  (subject + 2*\\n + body).\n>\n>Ah, makes sense.  In that case, \"%M\" maybe?\n\n I think it's no longer needed if instead of \"<undefined>\" only \"\" will\n be substituted.\n\n>> >> I made it because I want to use my own pretty format which currently \n>> >> only allows '%s' for subject and '%b' for body. But '%b' is \n>> >> substituted with <undefined> if the body is \"missing\" which I \n>> >> obviously don't like :)\n>> >\n>> >Then you should fix %b not to show \"<undefined>\".\n>> \n>>  I'll do it if it is okay. Shall I do the same for the other\n>>  placeholders as well?\n>\n>Yeah.  Don't know why I did it that way.\n\n Here comes the big patch :)\n\n\n>From 2e4ba4e73bbcd19558039dd85fe45c7bbe7fd1c4 Mon Sep 17 00:00:00 2001\nFrom: Michal Vitecek <fuf@mageo.cz>\nDate: Fri, 21 Sep 2007 14:40:37 +0200\nSubject: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders\n\n---\n commit.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 99f65ce..7e90bc1 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -919,7 +919,7 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t\ttable[IBODY].value = xstrdup(msg + i);\n \tfor (i = 0; i < ARRAY_SIZE(table); i++)\n \t\tif (!table[i].value)\n-\t\t\tinterp_set_entry(table, i, \"<unknown>\");\n+\t\t\tinterp_set_entry(table, i, \"\");\n \n \tdo {\n \t\tchar *buf = *buf_p;\n-- \n1.5.3.1\n\n-- \n\t\tfuf\t\t(fuf@mageo.cz)\n"},{"id":"53743","messageId":"7vk5qjixqy.fsf@gitster.siamese.dyndns.org","threadId":"9958","inReplyTo":"20070921140500.GB9072@mageo.cz","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-21T20:12:21Z","receivedAt":"2007-09-21T20:12:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michal Vitecek <fuf@mageo.cz> writes:\n\n[jc: Added Dscho back on CC: list]\n\n>>> >> I made it because I want to use my own pretty format which currently \n>>> >> only allows '%s' for subject and '%b' for body. But '%b' is \n>>> >> substituted with <undefined> if the body is \"missing\" which I \n>>> >> obviously don't like :)\n>>> >\n>>> >Then you should fix %b not to show \"<undefined>\".\n>>> \n>>>  I'll do it if it is okay. Shall I do the same for the other\n>>>  placeholders as well?\n>>\n>>Yeah.  Don't know why I did it that way.\n>\n>  Here comes the big patch :)\n\nNow, this breaks t6006 which needs this patch.\n\nLooking at this patch, I am not sure if your change is really a\ndesirable one --- shouldn't it be removing the line itself, not\njust <unknown> token?\n\n---\n t/t6006-rev-list-format.sh |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex ad6d0b8..2be323c 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -79,9 +79,9 @@ EOF\n \n test_format encoding %e <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n+\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+\n EOF\n \n test_format subject %s <<'EOF'\n@@ -93,9 +93,9 @@ EOF\n \n test_format body %b <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n+\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+\n EOF\n \n test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n@@ -121,9 +121,9 @@ test_format complex-encoding %e <<'EOF'\n commit f58db70b055c5718631e5c61528b28b12090cdea\n iso8859-1\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n+\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+\n EOF\n \n test_format complex-subject %s <<'EOF'\n@@ -142,9 +142,9 @@ and it will be encoded in iso8859-1. We should therefore\n include an iso8859 character: 臓bueno!\n \n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n+\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+\n EOF\n \n test_done\n"},{"id":"53748","messageId":"Pine.LNX.4.64.0709212141060.28395@racer.site","threadId":"9958","inReplyTo":"7vk5qjixqy.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-21T20:41:30Z","receivedAt":"2007-09-21T20:41:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 21 Sep 2007, Junio C Hamano wrote:\n\n> Michal Vitecek <fuf@mageo.cz> writes:\n> \n> [jc: Added Dscho back on CC: list]\n\nThanks.  I missed that one.  My comment would have been exactly the same.\n\nCiao,\nDscho\n"},{"id":"53797","messageId":"46F4D815.5050602@mageo.cz","threadId":"9958","inReplyTo":"7vk5qjixqy.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-22T08:53:41Z","receivedAt":"2007-09-22T08:53:41Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":"Junio C Hamano wrote:\n>>>>>> I made it because I want to use my own pretty format which currently \n>>>>>> only allows '%s' for subject and '%b' for body. But '%b' is \n>>>>>> substituted with <undefined> if the body is \"missing\" which I \n>>>>>> obviously don't like :)\n>>>>> Then you should fix %b not to show \"<undefined>\".\n>>>>  I'll do it if it is okay. Shall I do the same for the other\n>>>>  placeholders as well?\n>>> Yeah.  Don't know why I did it that way.\n>>  Here comes the big patch :)\n> \n> Now, this breaks t6006 which needs this patch.\n\nOops - I'm sorry about that. I ran the test suite (1.5.3.1) but it \nfailed in 2 tests before the patch and in 2 tests after it so I \nconsidered it okay.\n\n> Looking at this patch, I am not sure if your change is really a\n> desirable one --- shouldn't it be removing the line itself, not\n> just <unknown> token?\n\nThis sounds as the best solution. I'll look into it. Thanks for your time.\n\n-- \n\t\tfuf\t\t\t\t\t(fuf@mageo.cz)\n"},{"id":"53973","messageId":"20070925094320.GN22869@mageo.cz","threadId":"9958","inReplyTo":"46F4D815.5050602@mageo.cz","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-25T09:43:20Z","receivedAt":"2007-09-25T09:43:20Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":" Hello again,\n\nMichal Vitecek wrote:\n> Junio C Hamano wrote:\n>>>>>>> I made it because I want to use my own pretty format which currently \n>>>>>>> only allows '%s' for subject and '%b' for body. But '%b' is \n>>>>>>> substituted with <undefined> if the body is \"missing\" which I \n>>>>>>> obviously don't like :)\n>>>>>> Then you should fix %b not to show \"<undefined>\".\n>>>>>  I'll do it if it is okay. Shall I do the same for the other\n>>>>>  placeholders as well?\n>>>> Yeah.  Don't know why I did it that way.\n>>>  Here comes the big patch :)\n>> Now, this breaks t6006 which needs this patch.\n>\n> Oops - I'm sorry about that. I ran the test suite (1.5.3.1) but it failed \n> in 2 tests before the patch and in 2 tests after it so I considered it \n> okay.\n>\n>> Looking at this patch, I am not sure if your change is really a\n>> desirable one --- shouldn't it be removing the line itself, not\n>> just <unknown> token?\n>\n> This sounds as the best solution. I'll look into it. Thanks for your time.\n\n Here comes the patch. I hope it will be ok this time :) Thanks.\n\n Don't use \"<unknown>\" for unknown values of placeholders and suppress\n printing of empty user formats.\n\n---\n builtin-rev-list.c         |    3 ++-\n commit.c                   |    3 ---\n interpolate.c              |    6 +++++-\n log-tree.c                 |   10 ++++++----\n t/t6006-rev-list-format.sh |    8 --------\n t/t7500-commit.sh          |    4 ++--\n 6 files changed, 15 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 3894633..1de981d 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -85,7 +85,8 @@ static void show_commit(struct commit *commit)\n \t\tpretty_print_commit(revs.commit_format, commit, ~0,\n \t\t\t\t    &buf, &buflen,\n \t\t\t\t    revs.abbrev, NULL, NULL, revs.date_mode);\n-\t\tprintf(\"%s%c\", buf, hdr_termination);\n+                if (strlen(buf))\n+                    printf(\"%s%c\", buf, hdr_termination);\n \t\tfree(buf);\n \t}\n \tmaybe_flush_or_die(stdout, \"stdout\");\ndiff --git a/commit.c b/commit.c\nindex 99f65ce..c9a1818 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -917,9 +917,6 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t}\n \tif (msg[i])\n \t\ttable[IBODY].value = xstrdup(msg + i);\n-\tfor (i = 0; i < ARRAY_SIZE(table); i++)\n-\t\tif (!table[i].value)\n-\t\t\tinterp_set_entry(table, i, \"<unknown>\");\n \n \tdo {\n \t\tchar *buf = *buf_p;\ndiff --git a/interpolate.c b/interpolate.c\nindex 0082677..58fd055 100644\n--- a/interpolate.c\n+++ b/interpolate.c\n@@ -76,8 +76,12 @@ unsigned long interpolate(char *result, unsigned long reslen,\n \t\t\t/* Check for valid interpolation. */\n \t\t\tif (i < ninterps) {\n \t\t\t\tvalue = interps[i].value;\n-\t\t\t\tvaluelen = strlen(value);\n+                                if (value == NULL) {\n+                                    src += namelen;\n+                                    continue;\n+                                }\n \n+\t\t\t\tvaluelen = strlen(value);\n \t\t\t\tif (newlen + valuelen + 1 < reslen) {\n \t\t\t\t\t/* Substitute. */\n \t\t\t\t\tstrncpy(dest, value, valuelen);\ndiff --git a/log-tree.c b/log-tree.c\nindex a642371..5653332 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -175,14 +175,15 @@ void show_log(struct rev_info *opt, const char *sep)\n \t *  - The pretty-printed commit lacks a newline at the end\n \t *    of the buffer, but we do want to make sure that we\n \t *    have a newline there. If the separator isn't already\n-\t *    a newline, add an extra one.\n+         *    a newline, add an extra one and do the same for the\n+         *    user format as well.\n \t *  - unlike other log messages, the one-line format does\n \t *    not have an empty line between entries.\n \t */\n \textra = \"\";\n-\tif (*sep != '\\n' && opt->commit_format == CMIT_FMT_ONELINE)\n+\tif (*sep != '\\n' && (opt->commit_format == CMIT_FMT_ONELINE || opt->commit_format == CMIT_FMT_USERFORMAT))\n \t\textra = \"\\n\";\n-\tif (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)\n+\tif (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE && opt->commit_format != CMIT_FMT_USERFORMAT)\n \t\tputchar(opt->diffopt.line_termination);\n \topt->shown_one = 1;\n \n@@ -298,7 +299,8 @@ void show_log(struct rev_info *opt, const char *sep)\n \tif (opt->show_log_size)\n \t\tprintf(\"log size %i\\n\", len);\n \n-\tprintf(\"%s%s%s\", msgbuf, extra, sep);\n+        if (strlen(msgbuf))\n+            printf(\"%s%s%s\", msgbuf, extra, sep);\n \tfree(msgbuf);\n }\n \ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex ad6d0b8..1e4541a 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -79,9 +79,7 @@ EOF\n \n test_format encoding %e <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format subject %s <<'EOF'\n@@ -93,9 +91,7 @@ EOF\n \n test_format body %b <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n@@ -121,9 +117,7 @@ test_format complex-encoding %e <<'EOF'\n commit f58db70b055c5718631e5c61528b28b12090cdea\n iso8859-1\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format complex-subject %s <<'EOF'\n@@ -142,9 +136,7 @@ and it will be encoded in iso8859-1. We should therefore\n include an iso8859 character: ÂĄbueno!\n \n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_done\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex f11ada8..abbf54b 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -81,7 +81,7 @@ test_expect_success 'explicit commit message should override template' '\n \tgit add foo &&\n \tGIT_EDITOR=../t7500/add-content git commit --template \"$TEMPLATE\" \\\n \t\t-m \"command line msg\" &&\n-\tcommit_msg_is \"command line msg<unknown>\"\n+\tcommit_msg_is \"command line msg\"\n '\n \n test_expect_success 'commit message from file should override template' '\n@@ -90,7 +90,7 @@ test_expect_success 'commit message from file should override template' '\n \techo \"standard input msg\" |\n \t\tGIT_EDITOR=../t7500/add-content git commit \\\n \t\t\t--template \"$TEMPLATE\" --file - &&\n-\tcommit_msg_is \"standard input msg<unknown>\"\n+\tcommit_msg_is \"standard input msg\"\n '\n \n test_done\n-- \n1.5.3.1\n\n\n-- \n\t\tfuf\t\t(fuf@mageo.cz)\n"},{"id":"53978","messageId":"Pine.LNX.4.64.0709251120120.28395@racer.site","threadId":"9958","inReplyTo":"20070925094320.GN22869@mageo.cz","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-25T10:25:37Z","receivedAt":"2007-09-25T10:25:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Sep 2007, Michal Vitecek wrote:\n\n>  Hello again,\n> \n> Michal Vitecek wrote:\n> > Junio C Hamano wrote:\n> >>>>>>> I made it because I want to use my own pretty format which currently \n> >>>>>>> only allows '%s' for subject and '%b' for body. But '%b' is \n> >>>>>>> substituted with <undefined> if the body is \"missing\" which I \n> >>>>>>> obviously don't like :)\n> >>>>>> Then you should fix %b not to show \"<undefined>\".\n> >>>>>  I'll do it if it is okay. Shall I do the same for the other\n> >>>>>  placeholders as well?\n> >>>> Yeah.  Don't know why I did it that way.\n> >>>  Here comes the big patch :)\n> >> Now, this breaks t6006 which needs this patch.\n> >\n> > Oops - I'm sorry about that. I ran the test suite (1.5.3.1) but it failed \n> > in 2 tests before the patch and in 2 tests after it so I considered it \n> > okay.\n> >\n> >> Looking at this patch, I am not sure if your change is really a\n> >> desirable one --- shouldn't it be removing the line itself, not\n> >> just <unknown> token?\n> >\n> > This sounds as the best solution. I'll look into it. Thanks for your time.\n> \n>  Here comes the patch. I hope it will be ok this time :) Thanks.\n> \n>  Don't use \"<unknown>\" for unknown values of placeholders and suppress\n>  printing of empty user formats.\n> \n> ---\n\nPlease move the discussion which should not be in the commit message \n_after_ the \"---\".\n\n> diff --git a/builtin-rev-list.c b/builtin-rev-list.c\n> index 3894633..1de981d 100644\n> --- a/builtin-rev-list.c\n> +++ b/builtin-rev-list.c\n> @@ -85,7 +85,8 @@ static void show_commit(struct commit *commit)\n>  \t\tpretty_print_commit(revs.commit_format, commit, ~0,\n>  \t\t\t\t    &buf, &buflen,\n>  \t\t\t\t    revs.abbrev, NULL, NULL, revs.date_mode);\n> -\t\tprintf(\"%s%c\", buf, hdr_termination);\n> +                if (strlen(buf))\n> +                    printf(\"%s%c\", buf, hdr_termination);\n\nWe use tabs for indentation, not spaces.\n\nAlso, instead of the expensive \"strlen(buf)\", you rather want to check \"if \n(*buf)\".\n\n> diff --git a/log-tree.c b/log-tree.c\n> index a642371..5653332 100644\n> --- a/log-tree.c\n> +++ b/log-tree.c\n> @@ -298,7 +299,8 @@ void show_log(struct rev_info *opt, const char *sep)\n>  \tif (opt->show_log_size)\n>  \t\tprintf(\"log size %i\\n\", len);\n>  \n> -\tprintf(\"%s%s%s\", msgbuf, extra, sep);\n> +        if (strlen(msgbuf))\n> +            printf(\"%s%s%s\", msgbuf, extra, sep);\n\nAgain, \"if (*msgbuf)\" is way more efficient.\n\nCiao,\nDscho\n"},{"id":"53983","messageId":"20070925105201.GO22869@mageo.cz","threadId":"9958","inReplyTo":"Pine.LNX.4.64.0709251120120.28395@racer.site","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-25T10:52:02Z","receivedAt":"2007-09-25T10:52:02Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":" Hi,\n\nJohannes Schindelin wrote:\n>> >>>>>>> I made it because I want to use my own pretty format which currently \n>> >>>>>>> only allows '%s' for subject and '%b' for body. But '%b' is \n>> >>>>>>> substituted with <undefined> if the body is \"missing\" which I \n>> >>>>>>> obviously don't like :)\n>> >>>>>> Then you should fix %b not to show \"<undefined>\".\n>> >>>>>  I'll do it if it is okay. Shall I do the same for the other\n>> >>>>>  placeholders as well?\n>> >>>> Yeah.  Don't know why I did it that way.\n>> >>>  Here comes the big patch :)\n>> >> Now, this breaks t6006 which needs this patch.\n>> >\n>> > Oops - I'm sorry about that. I ran the test suite (1.5.3.1) but it failed \n>> > in 2 tests before the patch and in 2 tests after it so I considered it \n>> > okay.\n>> >\n>> >> Looking at this patch, I am not sure if your change is really a\n>> >> desirable one --- shouldn't it be removing the line itself, not\n>> >> just <unknown> token?\n>> >\n>> > This sounds as the best solution. I'll look into it. Thanks for your time.\n>> \n>>  Here comes the patch. I hope it will be ok this time :) Thanks.\n>> \n>>  Don't use \"<unknown>\" for unknown values of placeholders and suppress\n>>  printing of empty user formats.\n>> \n>> ---\n>\n>We use tabs for indentation, not spaces.\n>\n>Also, instead of the expensive \"strlen(buf)\", you rather want to check \"if \n>(*buf)\".\n\n---\n\n Thanks for the notes - here comes the patch with the above fixes.\n\n\n builtin-rev-list.c         |    3 ++-\n commit.c                   |    3 ---\n interpolate.c              |    6 +++++-\n log-tree.c                 |   10 ++++++----\n t/t6006-rev-list-format.sh |    8 --------\n t/t7500-commit.sh          |    4 ++--\n 6 files changed, 15 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 3894633..0b74eb3 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -85,7 +85,8 @@ static void show_commit(struct commit *commit)\n \t\tpretty_print_commit(revs.commit_format, commit, ~0,\n \t\t\t\t    &buf, &buflen,\n \t\t\t\t    revs.abbrev, NULL, NULL, revs.date_mode);\n-\t\tprintf(\"%s%c\", buf, hdr_termination);\n+\t\tif (*buf)\n+\t\t\tprintf(\"%s%c\", buf, hdr_termination);\n \t\tfree(buf);\n \t}\n \tmaybe_flush_or_die(stdout, \"stdout\");\ndiff --git a/commit.c b/commit.c\nindex 99f65ce..c9a1818 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -917,9 +917,6 @@ long format_commit_message(const struct commit *commit, const void *format,\n \t}\n \tif (msg[i])\n \t\ttable[IBODY].value = xstrdup(msg + i);\n-\tfor (i = 0; i < ARRAY_SIZE(table); i++)\n-\t\tif (!table[i].value)\n-\t\t\tinterp_set_entry(table, i, \"<unknown>\");\n \n \tdo {\n \t\tchar *buf = *buf_p;\ndiff --git a/interpolate.c b/interpolate.c\nindex 0082677..2f727cd 100644\n--- a/interpolate.c\n+++ b/interpolate.c\n@@ -76,8 +76,12 @@ unsigned long interpolate(char *result, unsigned long reslen,\n \t\t\t/* Check for valid interpolation. */\n \t\t\tif (i < ninterps) {\n \t\t\t\tvalue = interps[i].value;\n-\t\t\t\tvaluelen = strlen(value);\n+\t\t\t\tif (!value) {\n+\t\t\t\t\tsrc += namelen;\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n \n+\t\t\t\tvaluelen = strlen(value);\n \t\t\t\tif (newlen + valuelen + 1 < reslen) {\n \t\t\t\t\t/* Substitute. */\n \t\t\t\t\tstrncpy(dest, value, valuelen);\ndiff --git a/log-tree.c b/log-tree.c\nindex a642371..79502f4 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -175,14 +175,15 @@ void show_log(struct rev_info *opt, const char *sep)\n \t *  - The pretty-printed commit lacks a newline at the end\n \t *    of the buffer, but we do want to make sure that we\n \t *    have a newline there. If the separator isn't already\n-\t *    a newline, add an extra one.\n+         *    a newline, add an extra one and do the same for the\n+         *    user format as well.\n \t *  - unlike other log messages, the one-line format does\n \t *    not have an empty line between entries.\n \t */\n \textra = \"\";\n-\tif (*sep != '\\n' && opt->commit_format == CMIT_FMT_ONELINE)\n+\tif (*sep != '\\n' && (opt->commit_format == CMIT_FMT_ONELINE || opt->commit_format == CMIT_FMT_USERFORMAT))\n \t\textra = \"\\n\";\n-\tif (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)\n+\tif (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE && opt->commit_format != CMIT_FMT_USERFORMAT)\n \t\tputchar(opt->diffopt.line_termination);\n \topt->shown_one = 1;\n \n@@ -298,7 +299,8 @@ void show_log(struct rev_info *opt, const char *sep)\n \tif (opt->show_log_size)\n \t\tprintf(\"log size %i\\n\", len);\n \n-\tprintf(\"%s%s%s\", msgbuf, extra, sep);\n+\tif (*msgbuf)\n+\t\tprintf(\"%s%s%s\", msgbuf, extra, sep);\n \tfree(msgbuf);\n }\n \ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex ad6d0b8..1e4541a 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -79,9 +79,7 @@ EOF\n \n test_format encoding %e <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format subject %s <<'EOF'\n@@ -93,9 +91,7 @@ EOF\n \n test_format body %b <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n@@ -121,9 +117,7 @@ test_format complex-encoding %e <<'EOF'\n commit f58db70b055c5718631e5c61528b28b12090cdea\n iso8859-1\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_format complex-subject %s <<'EOF'\n@@ -142,9 +136,7 @@ and it will be encoded in iso8859-1. We should therefore\n include an iso8859 character: ÂĄbueno!\n \n commit 131a310eb913d107dd3c09a65d1651175898735d\n-<unknown>\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n EOF\n \n test_done\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex f11ada8..abbf54b 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -81,7 +81,7 @@ test_expect_success 'explicit commit message should override template' '\n \tgit add foo &&\n \tGIT_EDITOR=../t7500/add-content git commit --template \"$TEMPLATE\" \\\n \t\t-m \"command line msg\" &&\n-\tcommit_msg_is \"command line msg<unknown>\"\n+\tcommit_msg_is \"command line msg\"\n '\n \n test_expect_success 'commit message from file should override template' '\n@@ -90,7 +90,7 @@ test_expect_success 'commit message from file should override template' '\n \techo \"standard input msg\" |\n \t\tGIT_EDITOR=../t7500/add-content git commit \\\n \t\t\t--template \"$TEMPLATE\" --file - &&\n-\tcommit_msg_is \"standard input msg<unknown>\"\n+\tcommit_msg_is \"standard input msg\"\n '\n \n test_done\n-- \n1.5.3.2\n\n\n-- \n\t\tfuf\t\t(fuf@mageo.cz)\n"},{"id":"53988","messageId":"Pine.LNX.4.64.0709251345490.28395@racer.site","threadId":"9958","inReplyTo":"Pine.LNX.4.64.0709251120120.28395@racer.site","subject":"Re: [PATCH] Use \"\" instead of \"<unknown>\" for placeholders","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-25T12:46:47Z","receivedAt":"2007-09-25T12:46:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Sep 2007, Johannes Schindelin wrote:\n\n> On Tue, 25 Sep 2007, Michal Vitecek wrote:\n> \n> > [lots of quoted mails]\n> > \n> >  Here comes the patch. I hope it will be ok this time :) Thanks.\n> > \n> >  Don't use \"<unknown>\" for unknown values of placeholders and suppress\n> >  printing of empty user formats.\n> > \n> > ---\n> \n> Please move the discussion which should not be in the commit message \n> _after_ the \"---\".\n\nWhat about this comment?\n\nCiao,\nDscho\n"}]}