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:
git rev-list
andgit log
are essentially the same command
The answer is to use the following format:
# print out the log history in the desired format.
git log --pretty="format:..." <SHA-1>
There is literally no way to do this, unfortunately. git rev-list
is implemented thusly:
if (revs->abbrev_commit && revs->abbrev)
fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
stdout);
else
fputs(oid_to_hex(&commit->object.oid), stdout);
so no matter what options you put in, git rev-list
will always print some kind of commit hash.
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