Peeter Vois
Peeter Vois

Reputation: 86

How to override git log --format=oneline actual format?

I have hard issue to rule out (which I do not want to bother you). To rule that issue out, I have found that on my failing system the command

$ git log --pretty=oneline

is equivalent to:

$ git log --pretty=format:%H%x20%s

This makes the long hash output. At the same time

$ git log --oneline

makes short hash output. Which is the desired output.

On the not failing system the --pretty=oneline format is equivalent to:

$ git log --pretty=format:%h%x20%s

This makes short hash output.

I have been looking how to override the oneline configuration in git and it seems that the oneline is hard coded, i.e. I can not change the format with:

$ git config --global pretty.oneline %h%x20%s

I can make different pretty format

$ git config --global pretty.myline %h%x20%s

and it will show nicely the short hash with

$ git log --pretty=myline

The trouble is that I want to rule out the issue dependence to exact log command hash printout length. I can not use different command like

$ git log --pretty=format:%h%x20%s

Is there a way to override the pretty formats like oneline?

Upvotes: 4

Views: 1491

Answers (1)

Romain Valeri
Romain Valeri

Reputation: 21908

Your overall analysis is correct, I get what you'd want to achieve, but built-in pretty formats are unfortunately fixed.

From the doc :

Note that an alias with the same name as a built-in format will be silently ignored.


However, the difference between these two git environments might be leveled in some other way. Maybe consider getting both installations to the same git version?

Upvotes: 2

Related Questions