{"thread":{"id":"16876","subject":"[PATCH 1/3] pretty: factor out skip_empty_lines()","startedAt":"2008-12-27T00:32:49Z","lastAt":"2009-01-07T21:19:27Z","messageCount":15,"participants":["René Scharfe","Markus Heidelberg","Nanako Shiraishi","Junio C Hamano","Miklos Vajna"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"98759","messageId":"1230337969.8363.84.camel@ubuntu.ubuntu-domain","threadId":"16876","inReplyTo":null,"subject":"[PATCH 1/3] pretty: factor out skip_empty_lines()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-27T00:32:49Z","receivedAt":"2008-12-27T00:32:49Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The patch after the next one will use it.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n pretty.c |   24 +++++++++++++++---------\n 1 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex f6ff312..c43497b 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -181,6 +181,20 @@ static int is_empty_line(const char *line, int *len_p)\n \treturn !len;\n }\n \n+static const char *skip_empty_lines(const char *msg)\n+{\n+\tfor (;;) {\n+\t\tint linelen = get_one_line(msg);\n+\t\tint ll = linelen;\n+\t\tif (!linelen)\n+\t\t\tbreak;\n+\t\tif (!is_empty_line(msg, &ll))\n+\t\t\tbreak;\n+\t\tmsg += linelen;\n+\t}\n+\treturn msg;\n+}\n+\n static void add_merge_info(enum cmit_fmt fmt, struct strbuf *sb,\n \t\t\tconst struct commit *commit, int abbrev)\n {\n@@ -850,15 +864,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,\n \t}\n \n \t/* Skip excess blank lines at the beginning of body, if any... */\n-\tfor (;;) {\n-\t\tint linelen = get_one_line(msg);\n-\t\tint ll = linelen;\n-\t\tif (!linelen)\n-\t\t\tbreak;\n-\t\tif (!is_empty_line(msg, &ll))\n-\t\t\tbreak;\n-\t\tmsg += linelen;\n-\t}\n+\tmsg = skip_empty_lines(msg);\n \n \t/* These formats treat the title line specially. */\n \tif (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)\n-- \n1.6.1\n"},{"id":"98762","messageId":"1230338375.8363.91.camel@ubuntu.ubuntu-domain","threadId":"16876","inReplyTo":"1230337969.8363.84.camel@ubuntu.ubuntu-domain","subject":"[PATCH 2/3] pretty: factor out format_subject()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-27T00:39:35Z","receivedAt":"2008-12-27T00:39:35Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The next patch will use it.\n\nIn the version that was factored out, we can't rely on the len of the\nstruct strbuf to find out if a line separator needs to be added, as\nit might already contain something.  Add a guard variable (\"first\")\ninstead.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n pretty.c |   42 ++++++++++++++++++++++++------------------\n 1 files changed, 24 insertions(+), 18 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex c43497b..632abc5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -495,6 +495,28 @@ static void parse_commit_header(struct format_commit_context *context)\n \tcontext->commit_header_parsed = 1;\n }\n \n+static const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\t\t  const char *line_separator)\n+{\n+\tint first = 1;\n+\n+\tfor (;;) {\n+\t\tconst char *line = msg;\n+\t\tint linelen = get_one_line(line);\n+\n+\t\tmsg += linelen;\n+\t\tif (!linelen || is_empty_line(line, &linelen))\n+\t\t\tbreak;\n+\n+\t\tstrbuf_grow(sb, linelen + 2);\n+\t\tif (!first)\n+\t\t\tstrbuf_addstr(sb, line_separator);\n+\t\tstrbuf_add(sb, line, linelen);\n+\t\tfirst = 0;\n+\t}\n+\treturn msg;\n+}\n+\n static void format_decoration(struct strbuf *sb, const struct commit *commit)\n {\n \tstruct name_decoration *d;\n@@ -718,27 +740,11 @@ void pp_title_line(enum cmit_fmt fmt,\n \t\t   const char *encoding,\n \t\t   int need_8bit_cte)\n {\n+\tconst char *line_separator = (fmt == CMIT_FMT_EMAIL) ? \"\\n \" : \" \";\n \tstruct strbuf title;\n \n \tstrbuf_init(&title, 80);\n-\n-\tfor (;;) {\n-\t\tconst char *line = *msg_p;\n-\t\tint linelen = get_one_line(line);\n-\n-\t\t*msg_p += linelen;\n-\t\tif (!linelen || is_empty_line(line, &linelen))\n-\t\t\tbreak;\n-\n-\t\tstrbuf_grow(&title, linelen + 2);\n-\t\tif (title.len) {\n-\t\t\tif (fmt == CMIT_FMT_EMAIL) {\n-\t\t\t\tstrbuf_addch(&title, '\\n');\n-\t\t\t}\n-\t\t\tstrbuf_addch(&title, ' ');\n-\t\t}\n-\t\tstrbuf_add(&title, line, linelen);\n-\t}\n+\t*msg_p = format_subject(&title, *msg_p, line_separator);\n \n \tstrbuf_grow(sb, title.len + 1024);\n \tif (subject) {\n-- \n1.6.1\n"},{"id":"98765","messageId":"1230338961.8363.101.camel@ubuntu.ubuntu-domain","threadId":"16876","inReplyTo":"1230338375.8363.91.camel@ubuntu.ubuntu-domain","subject":"[PATCH 3/3] pretty: support multiline subjects with format:","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-27T00:49:21Z","receivedAt":"2008-12-27T00:49:21Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"git log --pretty=format:%s (and tformat:) used to display the first\nline of the subject, unlike the other --pretty options, which would\nconstruct a subject line from all lines of the first paragraph of\nthe commit message.\n\nFor consistency and increased code reuse, change format: to do the\nsame as the other options.\n\nBefore:\n\t$ git log --pretty=oneline v1.6.1 | md5sum\n\t7c0896d2a94fc3315a0372b9b3373a8f  -\n\t$ git log --pretty=tformat:\"%H %s\" v1.6.1 | md5sum\n\t298903b1c065002e15daa5329213c51f  -\n\nAfter:\n\t$ git log --pretty=tformat:\"%H %s\" v1.6.1 | md5sum\n\t7c0896d2a94fc3315a0372b9b3373a8f  -\n\t$ git log --pretty=oneline v1.6.1 | md5sum\n\t7c0896d2a94fc3315a0372b9b3373a8f  -\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n pretty.c |   53 ++++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 34 insertions(+), 19 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 632abc5..343dca5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -424,13 +424,15 @@ struct chunk {\n struct format_commit_context {\n \tconst struct commit *commit;\n \tenum date_mode dmode;\n+\tunsigned commit_header_parsed:1;\n+\tunsigned commit_message_parsed:1;\n \n \t/* These offsets are relative to the start of the commit message. */\n-\tint commit_header_parsed;\n-\tstruct chunk subject;\n \tstruct chunk author;\n \tstruct chunk committer;\n \tstruct chunk encoding;\n+\tsize_t message_off;\n+\tsize_t subject_off;\n \tsize_t body_off;\n \n \t/* The following ones are relative to the result struct strbuf. */\n@@ -460,23 +462,14 @@ static void parse_commit_header(struct format_commit_context *context)\n {\n \tconst char *msg = context->commit->buffer;\n \tint i;\n-\tenum { HEADER, SUBJECT, BODY } state;\n \n-\tfor (i = 0, state = HEADER; msg[i] && state < BODY; i++) {\n+\tfor (i = 0; msg[i]; i++) {\n \t\tint eol;\n \t\tfor (eol = i; msg[eol] && msg[eol] != '\\n'; eol++)\n \t\t\t; /* do nothing */\n \n-\t\tif (state == SUBJECT) {\n-\t\t\tcontext->subject.off = i;\n-\t\t\tcontext->subject.len = eol - i;\n-\t\t\ti = eol;\n-\t\t}\n \t\tif (i == eol) {\n-\t\t\tstate++;\n-\t\t\t/* strip empty lines */\n-\t\t\twhile (msg[eol] == '\\n' && msg[eol + 1] == '\\n')\n-\t\t\t\teol++;\n+\t\t\tbreak;\n \t\t} else if (!prefixcmp(msg + i, \"author \")) {\n \t\t\tcontext->author.off = i + 7;\n \t\t\tcontext->author.len = eol - i - 7;\n@@ -488,10 +481,8 @@ static void parse_commit_header(struct format_commit_context *context)\n \t\t\tcontext->encoding.len = eol - i - 9;\n \t\t}\n \t\ti = eol;\n-\t\tif (!msg[i])\n-\t\t\tbreak;\n \t}\n-\tcontext->body_off = i;\n+\tcontext->message_off = i;\n \tcontext->commit_header_parsed = 1;\n }\n \n@@ -508,6 +499,8 @@ static const char *format_subject(struct strbuf *sb, const char *msg,\n \t\tif (!linelen || is_empty_line(line, &linelen))\n \t\t\tbreak;\n \n+\t\tif (!sb)\n+\t\t\tcontinue;\n \t\tstrbuf_grow(sb, linelen + 2);\n \t\tif (!first)\n \t\t\tstrbuf_addstr(sb, line_separator);\n@@ -517,6 +510,21 @@ static const char *format_subject(struct strbuf *sb, const char *msg,\n \treturn msg;\n }\n \n+static void parse_commit_message(struct format_commit_context *c)\n+{\n+\tconst char *msg = c->commit->buffer + c->message_off;\n+\tconst char *start = c->commit->buffer;\n+\n+\tmsg = skip_empty_lines(msg);\n+\tc->subject_off = msg - start;\n+\n+\tmsg = format_subject(NULL, msg, NULL);\n+\tmsg = skip_empty_lines(msg);\n+\tc->body_off = msg - start;\n+\n+\tc->commit_message_parsed = 1;\n+}\n+\n static void format_decoration(struct strbuf *sb, const struct commit *commit)\n {\n \tstruct name_decoration *d;\n@@ -636,9 +644,6 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \t\tparse_commit_header(c);\n \n \tswitch (placeholder[0]) {\n-\tcase 's':\t/* subject */\n-\t\tstrbuf_add(sb, msg + c->subject.off, c->subject.len);\n-\t\treturn 1;\n \tcase 'a':\t/* author ... */\n \t\treturn format_person_part(sb, placeholder[1],\n \t\t\t\t   msg + c->author.off, c->author.len,\n@@ -650,6 +655,16 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \tcase 'e':\t/* encoding */\n \t\tstrbuf_add(sb, msg + c->encoding.off, c->encoding.len);\n \t\treturn 1;\n+\t}\n+\n+\t/* Now we need to parse the commit message. */\n+\tif (!c->commit_message_parsed)\n+\t\tparse_commit_message(c);\n+\n+\tswitch (placeholder[0]) {\n+\tcase 's':\t/* subject */\n+\t\tformat_subject(sb, msg + c->subject_off, \" \");\n+\t\treturn 1;\n \tcase 'b':\t/* body */\n \t\tstrbuf_addstr(sb, msg + c->body_off);\n \t\treturn 1;\n-- \n1.6.1\n"},{"id":"98820","messageId":"200812280024.59096.markus.heidelberg@web.de","threadId":"16876","inReplyTo":"1230338961.8363.101.camel@ubuntu.ubuntu-domain","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-27T23:24:58Z","receivedAt":"2008-12-27T23:24:58Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Hello,\n\nI hope I got the In-Reply-To right, the message was sent before my\nsubscription to this list.\n\nRené Scharfe, 27.12.2008:\n> git log --pretty=format:%s (and tformat:) used to display the first\n> line of the subject, unlike the other --pretty options, which would\n> construct a subject line from all lines of the first paragraph of\n> the commit message.\n\nAnd that can be very annoying when working on repositories with a\nhistory not formatted after the recommendations of git (empty line after\nthe summary). Then the output of commands like\n\"git log --pretty=oneline\", \"git format-patch\" and \"git show-branch\"\nis unreadable.\n\nSorry, I haven't tested your patch set, what is the output of\ngit-shortlog like now?\n\n> For consistency and increased code reuse, change format: to do the\n> same as the other options.\n\nWhat's wrong with using the first line instead of the first paragraph\nfor the other pretty options and for cases where only a small subject\nline is desired? A sentence would be broken into a small uncomplete part\nfor the subject for example. What else?\n\nMarkus\n"},{"id":"98822","messageId":"20081228090909.6117@nanako3.lavabit.com","threadId":"16876","inReplyTo":"200812280024.59096.markus.heidelberg@web.de","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2008-12-28T00:09:09Z","receivedAt":"2008-12-28T00:09:09Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Markus Heidelberg <markus.heidelberg@web.de>:\n\n>> For consistency and increased code reuse, change format: to do the\n>> same as the other options.\n>\n> What's wrong with using the first line instead of the first paragraph\n> for the other pretty options and for cases where only a small subject\n> line is desired?\n\nThere were too many issues. The mail archive tells us that there were considerable discussions and thoughts behind the current behavior:\n\n\thttp://thread.gmane.org/gmane.comp.version-control.git/49694/focus=49922\n\thttp://thread.gmane.org/gmane.comp.version-control.git/46341/focus=46818\n\thttp://thread.gmane.org/gmane.comp.version-control.git/54020/focus=54132\n\thttp://thread.gmane.org/gmane.comp.version-control.git/21949/focus=21987\n\nThe last message mentions a bug in \"git rebase\" that internally uses \"git am\" when replaying the changes. It was corrected later with:\n\n\thttp://thread.gmane.org/gmane.linux.ports.sh.devel/3833/focus=79735\n\nReading the discussion in the messages in this thread will help understanding the issues, after understanding why \"the first line\" was problematic, as discussed in the other threads.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"98823","messageId":"4956C47B.4020602@lsrfire.ath.cx","threadId":"16876","inReplyTo":"200812280024.59096.markus.heidelberg@web.de","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-28T00:12:43Z","receivedAt":"2008-12-28T00:12:43Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Markus Heidelberg schrieb:\n>> git log --pretty=format:%s (and tformat:) used to display the first\n>> line of the subject, unlike the other --pretty options, which would\n>> construct a subject line from all lines of the first paragraph of\n>> the commit message.\n> \n> And that can be very annoying when working on repositories with a\n> history not formatted after the recommendations of git (empty line after\n> the summary). Then the output of commands like\n> \"git log --pretty=oneline\", \"git format-patch\" and \"git show-branch\"\n> is unreadable.\n> \n> Sorry, I haven't tested your patch set, what is the output of\n> git-shortlog like now?\n\nIt's unchanged since it has it's own commit message parser.\n\n>> For consistency and increased code reuse, change format: to do the\n>> same as the other options.\n> \n> What's wrong with using the first line instead of the first paragraph\n> for the other pretty options and for cases where only a small subject\n> line is desired? A sentence would be broken into a small uncomplete part\n> for the subject for example. What else?\n\nI'm inching towards the goal of being able to replicate all of the other\n--pretty flavours with format: (or tformat:) strings.\n\n--pretty=oneline used to print only the first line, but was changed to\nthe way it's now in 4234a761 more than a year ago.  In my mind,\n\"subject\" is defined by \"what oneline is printing\", so I think changing\nthe format: placeholder %s to show the whole first paragraph is a bug fix.\n\nIf you actually like the old behaviour then perhaps a new placeholder\n(%S ?) should be introduced instead?\n\nRené\n"},{"id":"98824","messageId":"7vr63tb1i2.fsf@gitster.siamese.dyndns.org","threadId":"16876","inReplyTo":"200812280024.59096.markus.heidelberg@web.de","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-28T00:13:25Z","receivedAt":"2008-12-28T00:13:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Markus Heidelberg <markus.heidelberg@web.de> writes:\n\n> What's wrong with using the first line instead of the first paragraph\n> for the other pretty options and for cases where only a small subject\n> line is desired? A sentence would be broken into a small uncomplete part\n> for the subject for example. What else?\n\nThe \"first line\" actually was what we used to do originally.\n\ngit-native commits did not have problem with this behaviour, but it caused\ncountless complaints from people looking at the history converted from\nother cultures.\n\nThe behaviour was later fixed to avoid information loss when a commit from\na different culture begins the log with a long sentence, choped at\nmid-sentence, to continue to the second line.\n\nPlease check the list archive for the details (sorry, I am bit too lazy to\nrepeat the argument myself).\n"},{"id":"98828","messageId":"20081228014407.GD21154@genesis.frugalware.org","threadId":"16876","inReplyTo":"20081228090909.6117@nanako3.lavabit.com","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-12-28T01:44:07Z","receivedAt":"2008-12-28T01:44:07Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Sun, Dec 28, 2008 at 09:09:09AM +0900, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> The last message mentions a bug in \"git rebase\" that internally uses\n> \"git am\" when replaying the changes. It was corrected later with:\n> \n> \thttp://thread.gmane.org/gmane.linux.ports.sh.devel/3833/focus=79735\n> \n> Reading the discussion in the messages in this thread will help\n> understanding the issues, after understanding why \"the first line\" was\n> problematic, as discussed in the other threads.\n\nActually in that thread I asked if a patch that would make this\nconfigurable would be ever accepted (so I would work on it), but I got\nno answer. In the meantime I just learned to live with this, partially\nbecause the vim highlight script highlights anything written to the\nsecond line as red. ;-)\n"},{"id":"98837","messageId":"200812281508.02658.markus.heidelberg@web.de","threadId":"16876","inReplyTo":"20081228090909.6117@nanako3.lavabit.com","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-28T14:08:02Z","receivedAt":"2008-12-28T14:08:02Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Nanako Shiraishi, 28.12.2008:\n> Quoting Markus Heidelberg <markus.heidelberg@web.de>:\n> \n> >> For consistency and increased code reuse, change format: to do the\n> >> same as the other options.\n> >\n> > What's wrong with using the first line instead of the first paragraph\n> > for the other pretty options and for cases where only a small subject\n> > line is desired?\n> \n> There were too many issues. The mail archive tells us that there were\n> considerable discussions and thoughts behind the current behavior:\n\nMany thanks for all the pointers. I thought there were reasons, but this\nthread just made me ask.\n\nMarkus\n"},{"id":"98838","messageId":"200812281516.52080.markus.heidelberg@web.de","threadId":"16876","inReplyTo":"4956C47B.4020602@lsrfire.ath.cx","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-28T14:16:51Z","receivedAt":"2008-12-28T14:16:51Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"René Scharfe, 28.12.2008:\n> Markus Heidelberg schrieb:\n> >> For consistency and increased code reuse, change format: to do the\n> >> same as the other options.\n> > \n> > What's wrong with using the first line instead of the first paragraph\n> > for the other pretty options and for cases where only a small subject\n> > line is desired? A sentence would be broken into a small uncomplete part\n> > for the subject for example. What else?\n> \n> I'm inching towards the goal of being able to replicate all of the other\n> --pretty flavours with format: (or tformat:) strings.\n> \n> --pretty=oneline used to print only the first line, but was changed to\n> the way it's now in 4234a761 more than a year ago.  In my mind,\n> \"subject\" is defined by \"what oneline is printing\", so I think changing\n> the format: placeholder %s to show the whole first paragraph is a bug fix.\n\nYes, now I think so, too. I had also noticed the unexpectedly different\nbehaviour once.\n\n> If you actually like the old behaviour then perhaps a new placeholder\n> (%S ?) should be introduced instead?\n\nI don't need it. I rather asked regarding the old behaviour for oneline\nand so, but reading that there are strong intentions for their\nbehaviour, it's fine.\n\nMarkus\n"},{"id":"98839","messageId":"200812281526.22152.markus.heidelberg@web.de","threadId":"16876","inReplyTo":"7vr63tb1i2.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-28T14:26:21Z","receivedAt":"2008-12-28T14:26:21Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Junio C Hamano, 28.12.2008:\n> Markus Heidelberg <markus.heidelberg@web.de> writes:\n> \n> > What's wrong with using the first line instead of the first paragraph\n> > for the other pretty options and for cases where only a small subject\n> > line is desired? A sentence would be broken into a small uncomplete part\n> > for the subject for example. What else?\n> \n> The \"first line\" actually was what we used to do originally.\n> \n> git-native commits did not have problem with this behaviour, but it caused\n> countless complaints from people looking at the history converted from\n> other cultures.\n> \n> The behaviour was later fixed to avoid information loss when a commit from\n> a different culture begins the log with a long sentence, choped at\n> mid-sentence, to continue to the second line.\n> \n> Please check the list archive for the details (sorry, I am bit too lazy to\n> repeat the argument myself).\n\nI don't call this lazy. Normally I look myself and don't want others to\nspend time on searching for me. Reading that there already were\ndiscussions about this and that the current behaviour is thoughtful is\nenough for me to look for details myself. Thanks.\n\nMarkus\n"},{"id":"98920","messageId":"49594C16.2010406@lsrfire.ath.cx","threadId":"16876","inReplyTo":"4956C47B.4020602@lsrfire.ath.cx","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-29T22:15:50Z","receivedAt":"2008-12-29T22:15:50Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"René Scharfe schrieb:\n> Markus Heidelberg schrieb:\n>> Sorry, I haven't tested your patch set, what is the output of\n>> git-shortlog like now?\n> \n> It's unchanged since it has it's own commit message parser.\n\n... which displays the first line of the commit message, unlike\n--pretty=oneline.  Here's a quick fix.  I probably won't have time\nto come up with something prettier this year.\n\nRené\n\n\n builtin-shortlog.c |    9 ++++++---\n pretty.c           |    4 ++--\n 2 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex d03f14f..e492906 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -29,6 +29,9 @@ static int compare_by_number(const void *a1, const void *a2)\n \t\treturn -1;\n }\n \n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\t   const char *line_separator);\n+\n static void insert_one_record(struct shortlog *log,\n \t\t\t      const char *author,\n \t\t\t      const char *oneline)\n@@ -41,6 +44,7 @@ static void insert_one_record(struct shortlog *log,\n \tsize_t len;\n \tconst char *eol;\n \tconst char *boemail, *eoemail;\n+\tstruct strbuf subject = STRBUF_INIT;\n \n \tboemail = strchr(author, '<');\n \tif (!boemail)\n@@ -89,9 +93,8 @@ static void insert_one_record(struct shortlog *log,\n \twhile (*oneline && isspace(*oneline) && *oneline != '\\n')\n \t\toneline++;\n \tlen = eol - oneline;\n-\twhile (len && isspace(oneline[len-1]))\n-\t\tlen--;\n-\tbuffer = xmemdupz(oneline, len);\n+\tformat_subject(&subject, oneline, \" \");\n+\tbuffer = strbuf_detach(&subject, NULL);\n \n \tif (dot3) {\n \t\tint dot3len = strlen(dot3);\ndiff --git a/pretty.c b/pretty.c\nindex 343dca5..421d9c5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -486,8 +486,8 @@ static void parse_commit_header(struct format_commit_context *context)\n \tcontext->commit_header_parsed = 1;\n }\n \n-static const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t\t  const char *line_separator)\n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\t   const char *line_separator)\n {\n \tint first = 1;\n \n"},{"id":"99289","messageId":"7vocynz8y6.fsf@gitster.siamese.dyndns.org","threadId":"16876","inReplyTo":"49594C16.2010406@lsrfire.ath.cx","subject":"Re: [PATCH 3/3] pretty: support multiline subjects with format:","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-04T10:01:21Z","receivedAt":"2009-01-04T10:01:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n>> It's unchanged since it has it's own commit message parser.\n>\n> ... which displays the first line of the commit message, unlike\n> --pretty=oneline.  Here's a quick fix.  I probably won't have time\n> to come up with something prettier this year.\n\nI think the code is pretty enough ;-)  I just need to come up with a patch\ndescription and forge your Sign-off.\n\nThanks.\n"},{"id":"99509","messageId":"4963C1E2.8070906@lsrfire.ath.cx","threadId":"16876","inReplyTo":"7vocynz8y6.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 4/3] shortlog: handle multi-line subjects like log --pretty=oneline et. al. do","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-01-06T20:41:06Z","receivedAt":"2009-01-06T20:41:06Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The commit message parser of git shortlog used to treat only the first\nnon-empty line of the commit message as the subject.  Other log commands\n(e.g. --pretty=oneline) show the whole first paragraph instead (unwrapped\ninto a single line).\n\nFor consistency, this patch borrows format_subject() from pretty.c to\nmake shortlog do the same.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n builtin-shortlog.c |    9 ++++++---\n pretty.c           |    4 ++--\n 2 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex d03f14f..e492906 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -29,6 +29,9 @@ static int compare_by_number(const void *a1, const void *a2)\n \t\treturn -1;\n }\n \n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\t   const char *line_separator);\n+\n static void insert_one_record(struct shortlog *log,\n \t\t\t      const char *author,\n \t\t\t      const char *oneline)\n@@ -41,6 +44,7 @@ static void insert_one_record(struct shortlog *log,\n \tsize_t len;\n \tconst char *eol;\n \tconst char *boemail, *eoemail;\n+\tstruct strbuf subject = STRBUF_INIT;\n \n \tboemail = strchr(author, '<');\n \tif (!boemail)\n@@ -89,9 +93,8 @@ static void insert_one_record(struct shortlog *log,\n \twhile (*oneline && isspace(*oneline) && *oneline != '\\n')\n \t\toneline++;\n \tlen = eol - oneline;\n-\twhile (len && isspace(oneline[len-1]))\n-\t\tlen--;\n-\tbuffer = xmemdupz(oneline, len);\n+\tformat_subject(&subject, oneline, \" \");\n+\tbuffer = strbuf_detach(&subject, NULL);\n \n \tif (dot3) {\n \t\tint dot3len = strlen(dot3);\ndiff --git a/pretty.c b/pretty.c\nindex 343dca5..421d9c5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -486,8 +486,8 @@ static void parse_commit_header(struct format_commit_context *context)\n \tcontext->commit_header_parsed = 1;\n }\n \n-static const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t\t  const char *line_separator)\n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\t   const char *line_separator)\n {\n \tint first = 1;\n \n-- \n1.6.1\n"},{"id":"99617","messageId":"7vocyi95ls.fsf@gitster.siamese.dyndns.org","threadId":"16876","inReplyTo":"4963C1E2.8070906@lsrfire.ath.cx","subject":"Re: [PATCH 4/3] shortlog: handle multi-line subjects like log --pretty=oneline et. al. do","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-07T21:19:27Z","receivedAt":"2009-01-07T21:19:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> The commit message parser of git shortlog used to treat only the first\n> non-empty line of the commit message as the subject.  Other log commands\n> (e.g. --pretty=oneline) show the whole first paragraph instead (unwrapped\n> into a single line).\n>\n> For consistency, this patch borrows format_subject() from pretty.c to\n> make shortlog do the same.\n\nThanks; will queue.\n"}]}