{"thread":{"id":"7459","subject":"[PATCH] --pretty=format: print fewer <unknown>s","startedAt":"2007-03-28T22:09:14Z","lastAt":"2007-03-28T22:17:54Z","messageCount":3,"participants":["Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38272","messageId":"20070328220914.GA25389@coredump.intra.peff.net","threadId":"7459","inReplyTo":null,"subject":"[PATCH] --pretty=format: print fewer <unknown>s","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-03-28T22:09:14Z","receivedAt":"2007-03-28T22:09:14Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This makes empty bodies truly empty, and fills in the\ndefault UTF-8 encoding for an empty encoding.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n\nI think this covers everything that might happen in common practice.\n\n commit.c                   |    6 ++++--\n t/t6006-rev-list-format.sh |   16 ++++++++--------\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 754d1b8..e4f1db5 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -895,8 +895,10 @@ static long format_commit_message(const struct commit *commit,\n \t\t\t\txstrndup(msg + i + 9, eol - i - 9);\n \t\ti = eol;\n \t}\n-\tif (msg[i])\n-\t\ttable[IBODY].value = xstrdup(msg + i);\n+\tinterp_set_entry(table, IBODY, msg[i] ? msg + i : \"\");\n+\n+\tif (!table[IENCODING].value)\n+\t\tinterp_set_entry(table, IENCODING, \"UTF-8\");\n \tfor (i = 0; i < ARRAY_SIZE(table); i++)\n \t\tif (!table[i].value)\n \t\t\tinterp_set_entry(table, i, \"<unknown>\");\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex aab17fa..03ef6e0 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+UTF-8\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+UTF-8\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+UTF-8\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-<unknown>\n+UTF-8\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-- \n1.5.1.rc2.637.ge090-dirty\n"},{"id":"38274","messageId":"7v3b3pf245.fsf@assigned-by-dhcp.cox.net","threadId":"7459","inReplyTo":"20070328220914.GA25389@coredump.intra.peff.net","subject":"Re: [PATCH] --pretty=format: print fewer <unknown>s","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-28T22:13:30Z","receivedAt":"2007-03-28T22:13:30Z","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> This makes empty bodies truly empty, and fills in the\n> default UTF-8 encoding for an empty encoding.\n\nI do not think the latter is correct.  Replacing with an empty\nstring might make sense, although I haven't thought through the\nissues.\n"},{"id":"38276","messageId":"20070328221754.GB25430@coredump.intra.peff.net","threadId":"7459","inReplyTo":"7v3b3pf245.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] --pretty=format: print fewer <unknown>s","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-03-28T22:17:54Z","receivedAt":"2007-03-28T22:17:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 28, 2007 at 03:13:30PM -0700, Junio C Hamano wrote:\n\n> > This makes empty bodies truly empty, and fills in the\n> > default UTF-8 encoding for an empty encoding.\n> \n> I do not think the latter is correct.  Replacing with an empty\n> string might make sense, although I haven't thought through the\n> issues.\n\nFair enough. I originally put in an empty string, but tried to be (too)\nclever with UTF-8 (I was under the impression that commits without\nheaders were assumed to be in UTF-8, unless there is some legacy\noverride set). I'm fine with whatever makes sense, but I think printing\n<unknown> is silly: we _do_ know.\n\n-Peff\n"}]}