{"thread":{"id":"10012","subject":"[PATCH] Don't use \"<unknown>\" for unknown values of placeholders and suppress printing of empty user formats.","startedAt":"2007-09-25T14:38:46Z","lastAt":"2007-09-26T00:43:56Z","messageCount":3,"participants":["Michal Vitecek","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53998","messageId":"20070925143846.GQ22869@mageo.cz","threadId":"10012","inReplyTo":null,"subject":"[PATCH] Don't use \"<unknown>\" for unknown values of placeholders and suppress printing of empty user formats.","fromName":"Michal Vitecek","fromEmail":"fuf@mageo.cz","sentAt":"2007-09-25T14:38:46Z","receivedAt":"2007-09-25T14:38:46Z","isPatch":true,"sender":{"key":"fuf@mageo.cz","avatar":null},"body":"---\n\n Sending the patch again in correct form (hopefully) as instructed by\n Johannes Schindelin. Sorry for the hassle.\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\t\tfuf\t\t(fuf@mageo.cz)\n"},{"id":"54000","messageId":"Pine.LNX.4.64.0709251543561.28395@racer.site","threadId":"10012","inReplyTo":"20070925143846.GQ22869@mageo.cz","subject":"Re: [PATCH] Don't use \"<unknown>\" for unknown values of placeholders and suppress printing of empty user formats.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-25T14:47:17Z","receivedAt":"2007-09-25T14:47:17Z","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> ---\n> \n>  Sending the patch again in correct form (hopefully) as instructed by\n>  Johannes Schindelin. Sorry for the hassle.\n\nThanks.\n\n> diff --git a/commit.c b/commit.c\n> index 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\nThis may have warranted a description in the commit message a la\n\n\tInstead of setting unknown entries to \"<unknown>\" in the \n\tinterp_table, we teach interpolate() to replace entries with \n\tNULL values by the empty string.\n\n> diff --git a/log-tree.c b/log-tree.c\n> index 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\nHere are still spaces instead of tabs.\n\nThese are only minor details; I don't know if Junio wants to fix them \nhimself.\n\nCiao,\nDscho\n"},{"id":"54071","messageId":"7vwsue1cj7.fsf@gitster.siamese.dyndns.org","threadId":"10012","inReplyTo":"Pine.LNX.4.64.0709251543561.28395@racer.site","subject":"Re: [PATCH] Don't use \"<unknown>\" for unknown values of placeholders and suppress printing of empty user formats.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-26T00:43:56Z","receivedAt":"2007-09-26T00:43:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> This may have warranted a description in the commit message a la\n>\n> \tInstead of setting unknown entries to \"<unknown>\" in the \n> \tinterp_table, we teach interpolate() to replace entries with \n> \tNULL values by the empty string.\n\nIndeed.\n\n> Here are still spaces instead of tabs.\n>\n> These are only minor details; I don't know if Junio wants to fix them \n> himself.\n\nGood eyes.\n\nAlso a sign-off is missing ;-)\n"}]}