git log format: How to remove leading space from %d (ref names) placeholder?

Viewed 87

Currently, I have this setting:

format='%C(bold blue)%s'           # Commit subject
format+='%C(auto)%d%n'             # (HEAD -> master, origin/master)\n
format+='%C(yellow)%h%C(reset) '   # 4ae4a86
format+='%an, '                    # John Doe,
format+='%C(magenta)%ar%C(reset) ' # 3 days ago
format+='at %C(cyan)%ad%n'         # at 14:17\n   (--date=format:%H:%M)
format+='%b'                       # Commit body
alias gl="git log --graph --all --pretty='$format' --date=format:%H:%M"
unset format

Which gives this:

current git log format

Like git log --graph --oneline --all:

git log --graph --oneline --all

I want to swap the %d (ref names) with %s (subject):

format='%C(auto)%d '               # (HEAD -> master, origin/master)
format+='%C(bold blue)%s%n'        # Commit subject\n

But it gives a leading space:

first attempt

As an alternative to %d, there's %D, which removes the leading space and the parantheses. So I replaced %d with %D and wrap it in parentheses:

format='%C(auto)(%D) '             # (HEAD -> master, origin/master)

But now it looks like this:

latest attempt

So, how to remove the leading space from %d while still retaining the parentheses?

0 Answers
Related