{"thread":{"id":"15660","subject":"[PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines","startedAt":"2008-09-24T23:10:54Z","lastAt":"2008-09-24T23:10:54Z","messageCount":1,"participants":["Johan Herland"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91539","messageId":"200809250110.54229.johan@herland.net","threadId":"15660","inReplyTo":null,"subject":"[PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-24T23:10:54Z","receivedAt":"2008-09-24T23:10:54Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"'git for-each-ref --format=%(subject)' currently returns an empty string\nif the log message does not contain a newline.\n\nThis patch teaches 'git for-each-ref' to return the entire log message\n(instead of an empty string) if there is no newline in the log message.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n\nNormally, log messages in git have trailing newlines. However, it seems the\n\"tag fixup commits\" manufactured by cvs2svn/cvs2git (via git-fast-import)\nhave single-line log message without trailing newlines.\n\nI have checked the other callers of copy_line(), and AFAICS they are not\naffected by this change, since that would violate the git object format.\n\n\nHave fun! :)\n\n...Johan\n\n\n builtin-for-each-ref.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex 9b44092..e59bd80 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -321,8 +321,8 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un\n static const char *copy_line(const char *buf)\n {\n \tconst char *eol = strchr(buf, '\\n');\n-\tif (!eol)\n-\t\treturn \"\";\n+\tif (!eol) // simulate strchrnul()\n+\t\teol = buf + strlen(buf);\n \treturn xmemdupz(buf, eol - buf);\n }\n \n-- \n1.6.0.2.463.g7f0eb\n"}]}