I'd like to always show Author Name and Author Date, but optionally show Committer Name and Committer Date if they are different from Author Name and Date.
This is mainly for use after a rebase. The Author info remains the same, but the Committer info changes. If and only if they are different, I'd like to show the Committer info in addition to the Author info.
Author and Committer info are the same:
%C(yellow)%h%Creset %s %C(cyan)(%an - %ar)%Creset
Different:
%C(yellow)%h%Creset %s %C(cyan)(%an - %ar, %cn - %cr)%Creset
Is this possible?
1 Answer 1
There are no conditionals in the format arguments, and no format string that expands conditionally like that, so: no. On the other hand, you could extract the information from a commit manually (in a script), compare, and then choose which format to apply to that one commit, so: yes, if you're willing to do this outside of the git log
command.
For showing a single commit, the latter seems reasonable. For looking at the whole log, I suspect it would be very painful. :-) (Could still be done, use git rev-list
to generate the list of revs, then git log
each, one at a time, piping the whole result through the same pager git log
would use, etc. But... painful.)