3

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?

asked Jan 31, 2014 at 16:58

1 Answer 1

3

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.)

answered Jan 31, 2014 at 17:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.