Skip to content

Commit

Permalink
Merge branch 'eb/unpretty-b-format'
Browse files Browse the repository at this point in the history
* eb/unpretty-b-format:
  Add `%B' in format strings for raw commit body in `git log' and friends
  • Loading branch information
Junio C Hamano committed May 9, 2010
2 parents ea28bae + 1367b12 commit 67e5c87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/pretty-formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ The placeholders are:
- '%s': subject
- '%f': sanitized subject line, suitable for a filename
- '%b': body
- '%B': raw body (unwrapped subject and body)
- '%N': commit notes
- '%gD': reflog selector, e.g., `refs/stash@\{1\}`
- '%gd': shortened reflog selector, e.g., `stash@\{1\}`
Expand Down
4 changes: 4 additions & 0 deletions pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
return 1;
case 'B': /* raw body */
/* message_off is always left at the initial newline */
strbuf_addstr(sb, msg + c->message_off + 1);
return 1;
}

/* Now we need to parse the commit message. */
Expand Down
9 changes: 9 additions & 0 deletions t/t6006-rev-list-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
EOF

test_format raw-body %B <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
changed foo
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
added foo
EOF

test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
foobarbazxyzzy
Expand Down

0 comments on commit 67e5c87

Please sign in to comment.