@matheusbsbs / matheus-bagliano / commits / 1367b12ad6
Fork 0

Add `%B' in format strings for raw commit body in `git log' and friends

Also update the documentation text and add a test. Signed-off-by: Eli Barzilay <eli@barzilay.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eli Barzilay committed Mar 24, 2010 at 22:51 UTC 1367b12ad623e28546ba40c435015d94e7fbb248
3 files changed +14
Documentation/pretty-formats.txt
+1
@@ -123,6 +123,7 @@ The placeholders are:
123 - '%s': subject
124 - '%f': sanitized subject line, suitable for a filename
125 - '%b': body
126 +- '%B': raw body (unwrapped subject and body)
127 - '%N': commit notes
128 - '%gD': reflog selector, e.g., `refs/stash@\{1\}`
129 - '%gd': shortened reflog selector, e.g., `stash@\{1\}`
pretty.c
+4
@@ -797,6 +797,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
797 case 'e': /* encoding */
798 strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
799 return 1;
800 + case 'B': /* raw body */
801 + /* message_off is always left at the initial newline */
802 + strbuf_addstr(sb, msg + c->message_off + 1);
803 + return 1;
804 }
805
806 /* Now we need to parse the commit message. */
t/t6006-rev-list-format.sh
+9
@@ -101,6 +101,15 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
101 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
102 EOF
103
104 +test_format raw-body %B <<'EOF'
105 +commit 131a310eb913d107dd3c09a65d1651175898735d
106 +changed foo
107 +
108 +commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
109 +added foo
110 +
111 +EOF
112 +
113 test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
114 commit 131a310eb913d107dd3c09a65d1651175898735d
115 foobarbazxyzzy