Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude Preceding Commit> line from git rev-list formatting

Tags:

git

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?

like image 826
Brandon Anzaldi Avatar asked Apr 28 '16 23:04

Brandon Anzaldi


2 Answers

To leave an answer for those who will come next/

@torec mentioned in his comment the following:

git rev-list and git 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>
like image 66
CodeWizard Avatar answered Nov 12 '22 10:11

CodeWizard


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.

like image 40
ash Avatar answered Nov 12 '22 10:11

ash