Is there a way to specify the max length of the subject in the format string for git --for-each-ref
? I'd have a handy shortcut that lists my branches and the subject of the most recent commit, but I'd like to truncate the length of the subject field so that the output doesn't wrap. On a whim, I tried %(subject:short)
but git says
fatal: %(subject) does not take arguments
You can use bash
to display fields and limit the length with %.XXs
:
git for-each-ref --count=1 --sort='-*authordate' \
--format='%(*refname)|%(*authorname)|%(*authoremail)|%(*subject)|%(*authordate)' 'refs/tags' | \
while IFS='|' read refname authorname authoremail subject authordate
do
echo "Ref : $refname"
echo "From : $authorname $authoremail"
printf "Subject : %.30s\n" "$subject"
echo "Date : $authordate"
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With