Reputation: 53321
Our merge commit messages look like this (GitHub creates this format automatically):
Merge pull request #123 from repo/branch-a
Some change (title of the PR)
I can use --pretty=format:"%s: %b"
(%s
is "subject", %b
is "body") to get an output like this:
* Merge pull request #123 from repo/branch-a: Some change
* Merge pull request #456 from repo/branch-b: Another change
I'd like to transform the output to this:
* PR #123: Some change
* PR #456: Another change
Can this be done via --pretty
alone or do I need to pipe it to another program that will make the transformation? What would you do to get the same coloring and pagination (via $PAGER
; less
in my case) that plain git log
does?
UPDATE: the full command I run is this:
git log --color --graph --pretty=format:\"%Cred%h%Creset -%C(yellow)%d%Creset %b: %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\" --abbrev-commit --merges --first-parent
Upvotes: 0
Views: 217
Reputation: 1455
I think this should work:
YOURCOMMAND | sed 's/Merge pull request \#\([1-9]\).*\:\(.*\)/PR #\1: \2/g'
Just no colors here
Upvotes: 1
Reputation: 488599
The short answer is no: --pretty
has a lot of format directives, but none of them allow regex substitution.
What would you do to get the same coloring and pagination (via
$PAGER
;less
in my case) that plain git log does?
Plain git log
, with no options at all, does some color switching you can't quite get with any pretty format (I consider this a very minor bug). The main thing to get color controls out of git log
when piping git log
output (so as to do regex work or whatever) is to use the --color=always
switch. To get the pager to run, use git var GIT_PAGER
to find which pager to run, then run it.
Upvotes: 1