{"thread":{"id":"29215","subject":"[PATCH] Specify a precision for the length of a subject string","startedAt":"2011-12-20T22:07:54Z","lastAt":"2011-12-23T23:03:32Z","messageCount":15,"participants":["Nathan W. Panike","Thomas Rast","Nathan Panike","Jeff King","Andreas Schwab","Miles Bader","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181543","messageId":"20111220220754.GC21353@llunet.cs.wisc.edu","threadId":"29215","inReplyTo":null,"subject":"[PATCH] Specify a precision for the length of a subject string","fromName":"Nathan W. Panike","fromEmail":"nathan.panike@gmail.com","sentAt":"2011-12-20T22:07:54Z","receivedAt":"2011-12-20T22:07:54Z","isPatch":true,"sender":{"key":"nathan.panike@gmail.com","avatar":"https://avatars.githubusercontent.com/u/389447?v=4"},"body":"We can specify the precision of a subject string, so that length the subjects\nviewed by the user do not grow beyond a bound set by the user, in a pretty\nformatted string\n\nThis makes it possible to do, e.g., \n\n$ git log --pretty='%h %s' d165204 -1\nd165204 git-p4: fix skipSubmitEdit regression\n\nWith this patch, the user can do\n\n$ git log --pretty='%h %30s' d165204 -1\nd165204 git-p4: fix skipSubmitEdit reg\n\nThis is useful when one is working on a system where the pager is lousy.\n---\nSince my colleagues tend to write long subject lines, I like to truncate them\nso they do not overwhelm my terminal.\n\n builtin/shortlog.c |    2 +-\n commit.h           |    2 +-\n pretty.c           |   35 +++++++++++++++++++++++++++--------\n 3 files changed, 29 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 37f3193..a5a07a3 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -98,7 +98,7 @@ static void insert_one_record(struct shortlog *log,\n \t}\n \twhile (*oneline && isspace(*oneline) && *oneline != '\\n')\n \t\toneline++;\n-\tformat_subject(&subject, oneline, \" \");\n+\tformat_subject(&subject, oneline, \" \", 0);\n \tbuffer = strbuf_detach(&subject, NULL);\n \n \tif (dot3) {\ndiff --git a/commit.h b/commit.h\nindex 3745f12..a95f4ff 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -100,7 +100,7 @@ extern char *reencode_commit_message(const struct commit *commit,\n \t\t\t\t     const char **encoding_p);\n extern void get_commit_format(const char *arg, struct rev_info *);\n extern const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t\t  const char *line_separator);\n+\t\t\t\t  const char *line_separator, int max_len);\n extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n extern void format_commit_message(const struct commit *commit,\n \t\t\t\t  const char *format, struct strbuf *sb,\ndiff --git a/pretty.c b/pretty.c\nindex 230fe1c..3af7a95 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -738,24 +738,33 @@ static void format_sanitized_subject(struct strbuf *sb, const char *msg)\n }\n \n const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t   const char *line_separator)\n+\t\t\t   const char *line_separator, int max_len)\n {\n \tint first = 1;\n-\n+\tint swritten = 0;\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\tif (!sb)\n \t\t\tcontinue;\n+\t\tif (0 < max_len && max_len < swritten + linelen) {\n+\t\t\tlinelen = max_len - swritten;\t\n+\t\t\tif(linelen <= 0) {\n+\t\t\t\tlinelen = 0;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t}\n \t\tstrbuf_grow(sb, linelen + 2);\n-\t\tif (!first)\n+\t\tif (!first) {\n \t\t\tstrbuf_addstr(sb, line_separator);\n+\t\t\tswritten += strlen(line_separator);\n+\t\t}\n \t\tstrbuf_add(sb, line, linelen);\n+\t\tswritten += linelen;\n \t\tfirst = 0;\n \t}\n \treturn msg;\n@@ -769,7 +778,7 @@ static void parse_commit_message(struct format_commit_context *c)\n \tmsg = skip_empty_lines(msg);\n \tc->subject_off = msg - start;\n \n-\tmsg = format_subject(NULL, msg, NULL);\n+\tmsg = format_subject(NULL, msg, NULL, 0);\n \tmsg = skip_empty_lines(msg);\n \tc->body_off = msg - start;\n \n@@ -830,7 +839,17 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,\n \tconst char *msg = c->message;\n \tstruct commit_list *p;\n \tint h1, h2;\n+\tint subject_max_len = 0,offset=0;\n \n+\twhile(isdigit(*placeholder)) {\n+\t\tsubject_max_len *= 10;\n+\t\tsubject_max_len += *placeholder - '0';\n+\t\t++placeholder;\n+\t\t++offset;\n+\t}\n+\tif(offset > 0 && *placeholder != 's')\n+\t\tdie(\"invalid --pretty format: \"\n+\t\t    \"'%%(digits)' can only be followed by an s\");\n \t/* these are independent of the commit */\n \tswitch (placeholder[0]) {\n \tcase 'C':\n@@ -1002,8 +1021,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,\n \n \tswitch (placeholder[0]) {\n \tcase 's':\t/* subject */\n-\t\tformat_subject(sb, msg + c->subject_off, \" \");\n-\t\treturn 1;\n+\t\tformat_subject(sb, msg + c->subject_off, \" \",subject_max_len);\n+\t\treturn offset + 1;\n \tcase 'f':\t/* sanitized subject */\n \t\tformat_sanitized_subject(sb, msg + c->subject_off);\n \t\treturn 1;\n@@ -1189,7 +1208,7 @@ void pp_title_line(const struct pretty_print_context *pp,\n \n \tstrbuf_init(&title, 80);\n \t*msg_p = format_subject(&title, *msg_p,\n-\t\t\t\tpp->preserve_subject ? \"\\n\" : \" \");\n+\t\t\t\tpp->preserve_subject ? \"\\n\" : \" \",0);\n \n \tstrbuf_grow(sb, title.len + 1024);\n \tif (pp->subject) {\n-- \n1.7.8.352.g876a6f.dirty\n"},{"id":"181544","messageId":"87k45qriu2.fsf@thomas.inf.ethz.ch","threadId":"29215","inReplyTo":"20111220220754.GC21353@llunet.cs.wisc.edu","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-12-20T22:15:01Z","receivedAt":"2011-12-20T22:15:01Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"\"Nathan W. Panike\" <nathan.panike@gmail.com> writes:\n\n> This is useful when one is working on a system where the pager is lousy.\n\nI'm curious.  Are you saying your less does not have -S (or you do not\neven have less), or do you have a reason not to use it?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"181545","messageId":"20111220225014.GD21353@llunet.cs.wisc.edu","threadId":"29215","inReplyTo":"87k45qriu2.fsf@thomas.inf.ethz.ch","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Nathan Panike","fromEmail":"nwp@cs.wisc.edu","sentAt":"2011-12-20T22:50:15Z","receivedAt":"2011-12-20T22:50:15Z","isPatch":true,"sender":{"key":"nwp@cs.wisc.edu","avatar":null},"body":"On Tue, Dec 20, 2011 at 11:15:01PM +0100, Thomas Rast wrote:\n> \"Nathan W. Panike\" <nathan.panike@gmail.com> writes:\n> \n> > This is useful when one is working on a system where the pager is lousy.\n> \n> I'm curious.  Are you saying your less does not have -S (or you do not\n> even have less), or do you have a reason not to use it?\n> \n> -- \n> Thomas Rast\n> trast@{inf,student}.ethz.ch\n\nThe reason I thought of this initially was that I have a bot reporting commits\nat $dayjob in an IRC channel. Since some of my colleagues commit with long\nsubject lines, I thought of this as a way to control the output of the bot\n(e.g., by controlling the bot's input).\n\nNathan Panike\n"},{"id":"181559","messageId":"20111221043843.GA20714@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111220220754.GC21353@llunet.cs.wisc.edu","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-21T04:38:43Z","receivedAt":"2011-12-21T04:38:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 20, 2011 at 04:07:54PM -0600, Nathan W. Panike wrote:\n\n> We can specify the precision of a subject string, so that length the subjects\n> viewed by the user do not grow beyond a bound set by the user, in a pretty\n> formatted string\n> \n> This makes it possible to do, e.g., \n> \n> $ git log --pretty='%h %s' d165204 -1\n> d165204 git-p4: fix skipSubmitEdit regression\n> \n> With this patch, the user can do\n> \n> $ git log --pretty='%h %30s' d165204 -1\n> d165204 git-p4: fix skipSubmitEdit reg\n\nHmm. I think the idea of limiting is OK (though personally, I would just\npipe through a filter that truncates long lines). But I'm a bit negative\non adding a tweak like this that only affects the subject. Is there a\nreason I couldn't do %30gs, or %30f, or even some other placeholder?\n\nAlso, we already have %w to handle wrapping. Could this be handled in a\nsimilar way (perhaps it could even be considered a special form of\nwrapping)?\n\n-Peff\n"},{"id":"181570","messageId":"m2liq6go7y.fsf@igel.home","threadId":"29215","inReplyTo":"20111220220754.GC21353@llunet.cs.wisc.edu","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-12-21T11:26:25Z","receivedAt":"2011-12-21T11:26:25Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"\"Nathan W. Panike\" <nathan.panike@gmail.com> writes:\n\n> $ git log --pretty='%h %30s' d165204 -1\n\nIn C's formatted output this syntax denotes a minimum field width, not a\nprecision, so it will probably be surprising to many people.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"181575","messageId":"20111221145112.GA13097@llunet.cs.wisc.edu","threadId":"29215","inReplyTo":"20111221043843.GA20714@sigill.intra.peff.net","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Nathan Panike","fromEmail":"nwp@cs.wisc.edu","sentAt":"2011-12-21T14:51:13Z","receivedAt":"2011-12-21T14:51:13Z","isPatch":true,"sender":{"key":"nwp@cs.wisc.edu","avatar":null},"body":"On Tue, Dec 20, 2011 at 11:38:43PM -0500, Jeff King wrote:\n> On Tue, Dec 20, 2011 at 04:07:54PM -0600, Nathan W. Panike wrote:\n> \n> > We can specify the precision of a subject string, so that length the subjects\n> > viewed by the user do not grow beyond a bound set by the user, in a pretty\n> > formatted string\n> > \n> > This makes it possible to do, e.g., \n> > \n> > $ git log --pretty='%h %s' d165204 -1\n> > d165204 git-p4: fix skipSubmitEdit regression\n> > \n> > With this patch, the user can do\n> > \n> > $ git log --pretty='%h %30s' d165204 -1\n> > d165204 git-p4: fix skipSubmitEdit reg\n> \n> Hmm. I think the idea of limiting is OK (though personally, I would just\n> pipe through a filter that truncates long lines). But I'm a bit negative\n> on adding a tweak like this that only affects the subject. Is there a\n> reason I couldn't do %30gs, or %30f, or even some other placeholder?\n\nThe ones that make sense to limit are all those that depend on the subject, as the\nabove; it does not make sense to limit other fields that don't depend on the\nsubject, as they are fixed width, or have small variance. And it does not make\nsense to me to limit the length of the body.\n\n> \n> Also, we already have %w to handle wrapping. Could this be handled in a\n> similar way (perhaps it could even be considered a special form of\n> wrapping)?\n\nI'll look at the wrapping code and see. Thanks for the idea.\n> \n> -Peff\n"},{"id":"181576","messageId":"20111221145352.GB13097@llunet.cs.wisc.edu","threadId":"29215","inReplyTo":"m2liq6go7y.fsf@igel.home","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Nathan Panike","fromEmail":"nwp@cs.wisc.edu","sentAt":"2011-12-21T14:53:53Z","receivedAt":"2011-12-21T14:53:53Z","isPatch":true,"sender":{"key":"nwp@cs.wisc.edu","avatar":null},"body":"On Wed, Dec 21, 2011 at 12:26:25PM +0100, Andreas Schwab wrote:\n> \"Nathan W. Panike\" <nathan.panike@gmail.com> writes:\n> \n> > $ git log --pretty='%h %30s' d165204 -1\n> \n> In C's formatted output this syntax denotes a minimum field width, not a\n> precision, so it will probably be surprising to many people.\n\nC semantics are already broken because (from git-log(1))\n\n\"If you add a - (minus sign) after % of a placeholder, line-feeds that\nimmediately precede the expansion are deleted if and only if the placeholder\nexpands to an empty string.\"\n\nrather than indicating justification of the field.\n> \n> Andreas.\n> \n> -- \n> Andreas Schwab, schwab@linux-m68k.org\n> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n> \"And now for something completely different.\"\n"},{"id":"181632","messageId":"877h1nwrok.fsf@catnip.gol.com","threadId":"29215","inReplyTo":"20111221145352.GB13097@llunet.cs.wisc.edu","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-12-23T09:41:47Z","receivedAt":"2011-12-23T09:41:47Z","isPatch":true,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Nathan Panike <nwp@cs.wisc.edu> writes:\n>> > $ git log --pretty='%h %30s' d165204 -1\n>> \n>> In C's formatted output this syntax denotes a minimum field width, not a\n>> precision, so it will probably be surprising to many people.\n>\n> C semantics are already broken because (from git-log(1))\n>\n> \"If you add a - (minus sign) after % of a placeholder, line-feeds that\n> immediately precede the expansion are deleted if and only if the placeholder\n> expands to an empty string.\"\n>\n> rather than indicating justification of the field.\n\nThere's no reason to make it _worse_ though...\n\nFor your desired feature, why not just use the C printf syntax for this\nfunctionality, a leading dot before the max length?  E.g. \"%.30s\".\n\n-miles\n\n-- \nYouth, n. The Period of Possibility, when Archimedes finds a fulcrum,\nCassandra has a following and seven cities compete for the honor of endowing a\nliving Homer.\n"},{"id":"181633","messageId":"20111223100957.GA1247@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111221145112.GA13097@llunet.cs.wisc.edu","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T10:09:58Z","receivedAt":"2011-12-23T10:09:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 21, 2011 at 08:51:13AM -0600, Nathan Panike wrote:\n\n> > Hmm. I think the idea of limiting is OK (though personally, I would just\n> > pipe through a filter that truncates long lines). But I'm a bit negative\n> > on adding a tweak like this that only affects the subject. Is there a\n> > reason I couldn't do %30gs, or %30f, or even some other placeholder?\n> \n> The ones that make sense to limit are all those that depend on the subject, as the\n> above; it does not make sense to limit other fields that don't depend on the\n> subject, as they are fixed width, or have small variance. And it does not make\n> sense to me to limit the length of the body.\n\nI agree the subject is the most likely place. I was thinking one might\nwant to do it with the body, too. But whether it would be \"I want N\nbytes of the body\" or \"truncate each body line at N bytes without\nwrapping\", I don't know.\n\n-Peff\n"},{"id":"181634","messageId":"20111223103511.GA10029@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111223100957.GA1247@sigill.intra.peff.net","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T10:35:11Z","receivedAt":"2011-12-23T10:35:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 23, 2011 at 05:09:58AM -0500, Jeff King wrote:\n\n> > The ones that make sense to limit are all those that depend on the subject, as the\n> > above; it does not make sense to limit other fields that don't depend on the\n> > subject, as they are fixed width, or have small variance. And it does not make\n> > sense to me to limit the length of the body.\n> \n> I agree the subject is the most likely place. I was thinking one might\n> want to do it with the body, too. But whether it would be \"I want N\n> bytes of the body\" or \"truncate each body line at N bytes without\n> wrapping\", I don't know.\n\nAnother place that might want it is %N (commit notes).\n\nHere's how I would have done it. Not involving %w at all, but applying\nequally to all placeholders.\n\n  [1/2]: pretty: refactor --format \"magic\" placeholders\n  [2/2]: pretty: allow \"max-size\" magic for all placeholders\n\nI'm not personally interested in this topic, so I won't be pushing for\nthis to be included in git. But if it feels like the right direction for\nyou, feel free to be build on it and post it as part of your series (or\njust take it as inspiration and make your own commits). Off the top of\nmy head, it needs:\n\n  - documentation updates\n  - tests\n  - userformat_want_item should also respect the same magic (it already\n    duplicates some of the \"-/+/ \" magic. It might be nice to factor\n    that part out).\n\n-Peff\n"},{"id":"181635","messageId":"20111223103558.GA28036@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111223100957.GA1247@sigill.intra.peff.net","subject":"[PATCH 1/2] pretty: refactor --format \"magic\" placeholders","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T10:35:59Z","receivedAt":"2011-12-23T10:35:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Instead of assuming each magic token is a single character,\nlet's handle arbitrary-sized magic.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n pretty.c |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 230fe1c..7b4d098 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1018,6 +1018,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \t\t\t\t void *context)\n {\n \tint consumed;\n+\tint magic_len = 0;\n \tsize_t orig_len;\n \tenum {\n \t\tNO_MAGIC,\n@@ -1039,13 +1040,13 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \tdefault:\n \t\tbreak;\n \t}\n-\tif (magic != NO_MAGIC)\n+\tif (magic != NO_MAGIC) {\n+\t\tmagic_len++;\n \t\tplaceholder++;\n+\t}\n \n \torig_len = sb->len;\n \tconsumed = format_commit_one(sb, placeholder, context);\n-\tif (magic == NO_MAGIC)\n-\t\treturn consumed;\n \n \tif ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {\n \t\twhile (sb->len && sb->buf[sb->len - 1] == '\\n')\n@@ -1056,7 +1057,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \t\telse if (magic == ADD_SP_BEFORE_NON_EMPTY)\n \t\t\tstrbuf_insert(sb, orig_len, \" \", 1);\n \t}\n-\treturn consumed + 1;\n+\treturn consumed + magic_len;\n }\n \n static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,\n-- \n1.7.8.1.3.gba11d\n"},{"id":"181636","messageId":"20111223103639.GB28036@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111223100957.GA1247@sigill.intra.peff.net","subject":"[PATCH 2/2] pretty: allow \"max-size\" magic for all placeholders","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T10:36:39Z","receivedAt":"2011-12-23T10:36:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"You can now truncate a given placeholder to no more than a\ncertain number of characters with something like \"%30s\".\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis just uses the made-up \"%30s\" syntax, but you could easily tweak it\nto handle \"%.30s\" or whatever.\n\n pretty.c |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 7b4d098..06d96a7 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1019,6 +1019,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n {\n \tint consumed;\n \tint magic_len = 0;\n+\tint max_len = 0;\n \tsize_t orig_len;\n \tenum {\n \t\tNO_MAGIC,\n@@ -1045,9 +1046,22 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \t\tplaceholder++;\n \t}\n \n+\tif (isdigit(placeholder[0])) {\n+\t\tchar *end;\n+\t\tmax_len = strtoul(placeholder, &end, 10);\n+\t\tmagic_len += (end - placeholder);\n+\t\tplaceholder = end;\n+\t}\n+\n \torig_len = sb->len;\n \tconsumed = format_commit_one(sb, placeholder, context);\n \n+\tif (max_len) {\n+\t\tsize_t end = orig_len + max_len;\n+\t\tif (end < sb->len)\n+\t\t\tstrbuf_setlen(sb, end);\n+\t}\n+\n \tif ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {\n \t\twhile (sb->len && sb->buf[sb->len - 1] == '\\n')\n \t\t\tstrbuf_setlen(sb, sb->len - 1);\n-- \n1.7.8.1.3.gba11d\n"},{"id":"181651","messageId":"7v1urvc8fb.fsf@alter.siamese.dyndns.org","threadId":"29215","inReplyTo":"20111223103511.GA10029@sigill.intra.peff.net","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-23T20:58:00Z","receivedAt":"2011-12-23T20:58:00Z","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> Here's how I would have done it. Not involving %w at all, but applying\n> equally to all placeholders.\n\nHmm, just curious why you rejected the %w() approach, as enhancing %w\nsounded to me like a better approach at the design level, but that was a\nknee-jerk reaction without inspecting the codepaths involved myself hence\nnot knowing the potential amount of work required.\n\n>   - userformat_want_item should also respect the same magic (it already\n>     duplicates some of the \"-/+/ \" magic. It might be nice to factor\n>     that part out).\n\nI recall this was a bit of a bear when I looked at the area last time.\n"},{"id":"181655","messageId":"20111223230228.GA1718@sigill.intra.peff.net","threadId":"29215","inReplyTo":"7v1urvc8fb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T23:02:28Z","receivedAt":"2011-12-23T23:02:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 23, 2011 at 12:58:00PM -0800, Junio C Hamano wrote:\n\n> > Here's how I would have done it. Not involving %w at all, but applying\n> > equally to all placeholders.\n> \n> Hmm, just curious why you rejected the %w() approach, as enhancing %w\n> sounded to me like a better approach at the design level, but that was a\n> knee-jerk reaction without inspecting the codepaths involved myself hence\n> not knowing the potential amount of work required.\n\nNot so much rejecting as I took a quick look at how I would have done\nwhat your original patch did, and it was simple enough that I took it\nall the way to working and decided to post it. I left it up to you to\ndecide whether using %w would be more sensible. I just wanted to present\nanother alternative for discussion.\n\n-Peff\n"},{"id":"181656","messageId":"20111223230332.GA1734@sigill.intra.peff.net","threadId":"29215","inReplyTo":"20111223230228.GA1718@sigill.intra.peff.net","subject":"Re: [PATCH] Specify a precision for the length of a subject string","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-23T23:03:32Z","receivedAt":"2011-12-23T23:03:32Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 23, 2011 at 06:02:28PM -0500, Jeff King wrote:\n\n> On Fri, Dec 23, 2011 at 12:58:00PM -0800, Junio C Hamano wrote:\n> \n> > > Here's how I would have done it. Not involving %w at all, but applying\n> > > equally to all placeholders.\n> > \n> > Hmm, just curious why you rejected the %w() approach, as enhancing %w\n> > sounded to me like a better approach at the design level, but that was a\n> > knee-jerk reaction without inspecting the codepaths involved myself hence\n> > not knowing the potential amount of work required.\n> \n> Not so much rejecting as I took a quick look at how I would have done\n> what your original patch did, and it was simple enough that I took it\n> all the way to working and decided to post it. I left it up to you to\n> decide whether using %w would be more sensible. I just wanted to present\n> another alternative for discussion.\n\nEh, I misread the \"From\" header. All of the \"you\" there is \"Nathan\".\n\n-Peff\n"}]}