I'm trying to work on a branch diff command, and I've got it all working... Except for the formatting. I can use --pretty=oneline
to display just the information I want, except it displays the full hash, and doesn't colorize the output.
So it'd just output this:
fa73c05913292fbce940075fc8f454bad5066666 Example Commit Message
de4dbeffa249393dddebb7b13ae555cb97cad5be Another Example Commit Message
If I try and do a custom format string, such as this: --pretty="format:%C(yellow)%h%C(reset) %s"
, it works, but it also displays an additional line above it.
E.g.
commit >fa73c05913292fbce940075fc8f454bad5066666
fa73c05 Example Commit Message
commit >de4dbeffa249393dddebb7b13ae555cb97cad5be
de4dbef Another Example Commit Message
Is there a way to have git rev-list
output a format without the preceding commit >abcdef3...
lines?
To leave an answer for those who will come next/
@torec mentioned in his comment the following:
The answer is to use the following format:
You can use
sed
after git rev-list to delete all the lines starting withcommit
.git rev-list --pretty=format:"%C(yellow)%h%C(reset) %s" | sed '/^commit/d'
.There is literally no way to do this, unfortunately.
git rev-list
is implemented thusly:so no matter what options you put in,
git rev-list
will always print some kind of commit hash.