# Missing trailing newline with git log --pretty=format

4 messages from 2009-03-18 to 2009-03-18. Participants: Andreas Gruenbacher, Markus Heidelberg, Junio C Hamano.
Thread: https://gitlist.dev/t/18386

## Andreas Gruenbacher, 2009-03-18 21:23

Subject: Missing trailing newline with git log --pretty=format
Message-ID: <200903182223.58800.agruen@suse.de>
URL: https://gitlist.dev/e/200903182223.58800.agruen%40suse.de

```
Hello,

with the latest version of git from right now (e986ceb):

While trying to get a reverse list of commit ids, I noticed that git log 
prints newlines between commits, but not at the end. This results in two 
joined lines with:

	$ git log --pretty=format:%h HEAD^^..HEAD | tac
	aab3b9a7d4e3a7
	e986ceb

Any chance of getting this fixed?

Thanks,
Andreas

```

## Markus Heidelberg, 2009-03-18 21:56

Subject: Re: Missing trailing newline with git log --pretty=format
Message-ID: <200903182256.43817.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200903182256.43817.markus.heidelberg%40web.de
In-Reply-To: <200903182223.58800.agruen@suse.de>

```
Andreas Gruenbacher, 18.03.2009:
> Hello,
> 
> with the latest version of git from right now (e986ceb):
> 
> While trying to get a reverse list of commit ids, I noticed that git log 
> prints newlines between commits, but not at the end. This results in two 
> joined lines with:
> 
> 	$ git log --pretty=format:%h HEAD^^..HEAD | tac
> 	aab3b9a7d4e3a7
> 	e986ceb
> 
> Any chance of getting this fixed?

Use tformat instead of format. Or better for a script use

	$ git rev-list HEAD^^..HEAD

But somehow --abbrev or --abbrev-commit don't work. Am I doing
something wrong?

Markus

```

## Andreas Gruenbacher, 2009-03-18 22:04

Subject: Re: Missing trailing newline with git log --pretty=format
Message-ID: <200903182304.51387.agruen@suse.de>
URL: https://gitlist.dev/e/200903182304.51387.agruen%40suse.de
In-Reply-To: <200903182256.43817.markus.heidelberg@web.de>

```
On Wednesday, 18 March 2009 22:56:43 Markus Heidelberg wrote:
> Use tformat instead of format.

Hmm ... didn't know that, thanks. Now I wonder why anyone would ever want 
format instead of tformat ;)

> Or better for a script use 
>
> 	$ git rev-list HEAD^^..HEAD

Much better, thanks.

Andreas

```

## Junio C Hamano, 2009-03-18 22:27

Subject: Re: Missing trailing newline with git log --pretty=format
Message-ID: <7vzlfibh5w.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzlfibh5w.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200903182304.51387.agruen@suse.de>

```
Andreas Gruenbacher <agruen@suse.de> writes:

> On Wednesday, 18 March 2009 22:56:43 Markus Heidelberg wrote:
>> Use tformat instead of format.
>
> Hmm ... didn't know that, thanks. Now I wonder why anyone would ever want 
> format instead of tformat ;)

If your payload is multi-line, you would want to see a separating empty
line in between entries, but not after the last one:

	$ command with --format
        The first line of first entry.
        The second line of first entry.
        ...
        The last line of first entry.

        The first line of second entry.
        ...
        ...
        The last line of last entry.
        $ notice there is no extra newline after that

That is what --format does.  One-line-per-entry is a special case.  You do
not want a "separating LF in between entries", but a "terminating LF after
each entry".  T in --tformat stands for this "terminating" aspect, as
opposed to the "separator" behaviour --format gives you.

```
