{"thread":{"id":"23170","subject":"[PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","startedAt":"2010-03-25T02:51:52Z","lastAt":"2010-04-05T06:06:03Z","messageCount":6,"participants":["Eli Barzilay","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"137765","messageId":"19370.53192.313137.191218@winooski.ccs.neu.edu","threadId":"23170","inReplyTo":null,"subject":"[PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-03-25T02:51:52Z","receivedAt":"2010-03-25T02:51:52Z","isPatch":true,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"Also update the documentation text and add a test.\n\nSigned-off-by: Eli Barzilay <eli@barzilay.org>\n---\n\nThis is re a feature request I made a few days ago.  The test is\ntrivial, since there are only two commits with a single line.\n\n Documentation/pretty-formats.txt |    1 +\n pretty.c                         |    4 ++++\n t/t6006-rev-list-format.sh       |    9 +++++++++\n 3 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 1686a54..bd760d3 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -123,6 +123,7 @@ The placeholders are:\n - '%s': subject\n - '%f': sanitized subject line, suitable for a filename\n - '%b': body\n+- '%B': raw body (unwrapped subject and body)\n - '%N': commit notes\n - '%gD': reflog selector, e.g., `refs/stash@\\{1\\}`\n - '%gd': shortened reflog selector, e.g., `stash@\\{1\\}`\ndiff --git a/pretty.c b/pretty.c\nindex 6ba3da8..14c9568 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -797,6 +797,10 @@ static size_t format_commit_one(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+\tcase 'B':\t/* raw body */\n+\t\t/* message_off is always left at the initial newline */\n+\t\tstrbuf_addstr(sb, msg + c->message_off + 1);\n+\t\treturn 1;\n \t}\n \n \t/* Now we need to parse the commit message. */\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex b0047d3..5d15f18 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -101,6 +101,15 @@ commit 131a310eb913d107dd3c09a65d1651175898735d\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n EOF\n \n+test_format raw-body %B <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+changed foo\n+\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+added foo\n+\n+EOF\n+\n test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n \u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n-- \n1.7.0.3\n"},{"id":"138559","messageId":"m3eiiunbky.fsf@winooski.ccs.neu.edu","threadId":"23170","inReplyTo":"19370.53192.313137.191218@winooski.ccs.neu.edu","subject":"Re: [PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-04T21:37:33Z","receivedAt":"2010-04-04T21:37:33Z","isPatch":true,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"A while ago I sent the patch below.  There were no replies.  Is there\nanything else that I should do, or is there any problem in doing this?\n\n\nEli Barzilay <eli@barzilay.org> writes:\n\n> Also update the documentation text and add a test.\n>\n> Signed-off-by: Eli Barzilay <eli@barzilay.org>\n> ---\n>\n> This is re a feature request I made a few days ago.  The test is\n> trivial, since there are only two commits with a single line.\n>\n>  Documentation/pretty-formats.txt |    1 +\n>  pretty.c                         |    4 ++++\n>  t/t6006-rev-list-format.sh       |    9 +++++++++\n>  3 files changed, 14 insertions(+), 0 deletions(-)\n>\n> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> index 1686a54..bd760d3 100644\n> --- a/Documentation/pretty-formats.txt\n> +++ b/Documentation/pretty-formats.txt\n> @@ -123,6 +123,7 @@ The placeholders are:\n>  - '%s': subject\n>  - '%f': sanitized subject line, suitable for a filename\n>  - '%b': body\n> +- '%B': raw body (unwrapped subject and body)\n>  - '%N': commit notes\n>  - '%gD': reflog selector, e.g., `refs/stash@\\{1\\}`\n>  - '%gd': shortened reflog selector, e.g., `stash@\\{1\\}`\n> diff --git a/pretty.c b/pretty.c\n> index 6ba3da8..14c9568 100644\n> --- a/pretty.c\n> +++ b/pretty.c\n> @@ -797,6 +797,10 @@ static size_t format_commit_one(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> +\tcase 'B':\t/* raw body */\n> +\t\t/* message_off is always left at the initial newline */\n> +\t\tstrbuf_addstr(sb, msg + c->message_off + 1);\n> +\t\treturn 1;\n>  \t}\n>  \n>  \t/* Now we need to parse the commit message. */\n> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\n> index b0047d3..5d15f18 100755\n> --- a/t/t6006-rev-list-format.sh\n> +++ b/t/t6006-rev-list-format.sh\n> @@ -101,6 +101,15 @@ commit 131a310eb913d107dd3c09a65d1651175898735d\n>  commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n>  EOF\n>  \n> +test_format raw-body %B <<'EOF'\n> +commit 131a310eb913d107dd3c09a65d1651175898735d\n> +changed foo\n> +\n> +commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n> +added foo\n> +\n> +EOF\n> +\n>  test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n>  commit 131a310eb913d107dd3c09a65d1651175898735d\n>  foobarbazxyzzy\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"138564","messageId":"7v6346zwu1.fsf@alter.siamese.dyndns.org","threadId":"23170","inReplyTo":"m3eiiunbky.fsf@winooski.ccs.neu.edu","subject":"Re: [PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-04T22:17:42Z","receivedAt":"2010-04-04T22:17:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Isn't this the same as \"%s%n%+b\"?\n"},{"id":"138567","messageId":"19385.5077.27968.796350@winooski.ccs.neu.edu","threadId":"23170","inReplyTo":"7v6346zwu1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-04T22:33:57Z","receivedAt":"2010-04-04T22:33:57Z","isPatch":true,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"On Apr  4, Junio C Hamano wrote:\n> Isn't this the same as \"%s%n%+b\"?\n\nThe problem with that is that it wraps the first paragraph.  So it's\nfine as long as it's always used as a subject line.\n\n(I'm migrating a project to git, and some people will never remember\nto do that.)\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"138573","messageId":"7vljd2y9c2.fsf@alter.siamese.dyndns.org","threadId":"23170","inReplyTo":"19385.5077.27968.796350@winooski.ccs.neu.edu","subject":"Re: Re: [PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-05T01:30:37Z","receivedAt":"2010-04-05T01:30:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eli Barzilay <eli@barzilay.org> writes:\n\n> On Apr  4, Junio C Hamano wrote:\n>> Isn't this the same as \"%s%n%+b\"?\n>\n> The problem with that is that it wraps the first paragraph.  So it's\n> fine as long as it's always used as a subject line.\n>\n> (I'm migrating a project to git, and some people will never remember\n> to do that.)\n\nOk, but then \"rev-list --pretty=format:%B\" would not be as a good tool for\nmigration to begin with (imagine a log message that begins with \"commit\"),\ncompared to say \"rev-list --pretty=raw\".\n\nIt also feels a bit funny to list %B that doesn't do the paragraph\npretty-printing in pretty-formats.txt documentation ;-) but that is not an\nobjection.\n"},{"id":"138581","messageId":"19385.32203.489776.418681@winooski.ccs.neu.edu","threadId":"23170","inReplyTo":"7vljd2y9c2.fsf@alter.siamese.dyndns.org","subject":"Re: Re: [PATCH] Add `%B' in format strings for raw commit body in `git log' and friends","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-05T06:06:03Z","receivedAt":"2010-04-05T06:06:03Z","isPatch":true,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"On Apr  4, Junio C Hamano wrote:\n> Eli Barzilay <eli@barzilay.org> writes:\n> \n> > On Apr  4, Junio C Hamano wrote:\n> >> Isn't this the same as \"%s%n%+b\"?\n> >\n> > The problem with that is that it wraps the first paragraph.  So it's\n> > fine as long as it's always used as a subject line.\n> >\n> > (I'm migrating a project to git, and some people will never remember\n> > to do that.)\n> \n> Ok, but then \"rev-list --pretty=format:%B\" would not be as a good\n> tool for migration to begin with (imagine a log message that begins\n> with \"commit\"), compared to say \"rev-list --pretty=raw\".\n\nAh, sorry -- I phrased that poorely.  We're doing the actual migration\nwith git-svn, so that's not the problem.  The relation to migrating is\nthat people are not used to using the first paragraph as a subject\nline, which means that there will be commit messages that look like:\n\n  Fix foo, which means:\n  1. Do this,\n  2. Do that,\n  3. Remove bar.\n\nand such messages come out really ugly.  If a project is well behaved\nin regards to commit messages always having a subject line, then\nthere's no big problem, of course.  (It can be a little worse if I\nhave scripts that look for lines with a specific format like commands\nfor a bug tracking system.)\n\n\n> It also feels a bit funny to list %B that doesn't do the paragraph\n> pretty-printing in pretty-formats.txt documentation ;-) but that is\n> not an objection.\n\n(Well, my understanding was that the pretty formats is about the\nformat strings in general.)\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"}]}