Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-log

Given the following example git commit message:

My commit message summary

Some more body in this message...

Signed-off-by: My name <[email protected]>
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
like image 916
gertvdijk Avatar asked Nov 24 '17 14:11

gertvdijk


Video Answer


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)"
like image 198
sery Avatar answered Sep 16 '22 18:09

sery