Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the git pretty format equivalent of "medium"? (OR: why no LF in %s)

Tags:

git

I was trying to work out the git log --pretty=format:... equivalent for the default git log behaviour. I can find that the default is "medium", but cannot track down what pretty format string that corresponds to (so that I can copy parts of it).

My real question is why %s gives me the commit message as a single line, swallowing all the line-feeds (but otherwise the complete message). Whereas default git log behaviour not only preserves the line breaks but also gives it a nice indent. The full command I am experimenting with is:

git log --all --pretty=format:\"%h %cd%d%+s\" --name-status --date=local

(%s and %+s are identical with regards to the line-breaks within the commit message)

(git version 1.9.1)

like image 484
Darren Cook Avatar asked Jan 20 '15 11:01

Darren Cook


1 Answers

You can use the line wrapping format %w to reintroduce new lines by setting the width to 0.

%w(width[,<indent1>[,<indent2>]])

This format is equivalent to medium

git log --pretty="format:%C(yellow)commit %H%n%C(white)Author: %an <%ae>%nDate:   %ad%n%n%w(0,4,4)%B%n"
like image 176
René Link Avatar answered Sep 21 '22 00:09

René Link