Git: How to list specific trailers (footers) in git-log format?

Viewed 2330

Given the following example git commit message:

My commit message summary

Some more body in this message...

Signed-off-by: My name <my.name@example.com>
Issue: MYPROJ-123

I can now parse these 'trailers' (key/value parameters in the footer) with recent Git versions (2.14+) using git interpret-trailers --parse. This appears integrated into git-log formatting options as well, e.g.:

git log --format="%h %s %(trailers)"

However, it shows me all trailers, including the line breaks.

Would it be possible to limit this to the value(s) of a single trailer token? Ideally, what I'd like to accomplish is something like this as a git-log line, showing the value of the Issue token only:

0123abcd My commit message summary MYPROJ-123
1 Answers

This is possible using trailers options. Following your example the command line would be:

git log --format="%h %s %(trailers:key=Issue,valueonly)"
Related