# something like git-for-each-ref's --format for commits?

2 messages from 2008-01-06 to 2008-01-06. Participants: Brian Swetland, Jeff King.
Thread: https://gitlist.dev/t/11491

## Brian Swetland, 2008-01-06 08:52

Subject: something like git-for-each-ref's --format for commits?
Message-ID: <20080106085221.GA1729@bulgaria.corp.google.com>
URL: https://gitlist.dev/e/20080106085221.GA1729%40bulgaria.corp.google.com

```

I'm trying to obtain various information about commits from a script.
The --format option to git-for-each-ref would be perfect, except that
it only operates on refs, not arbitrary commit objects.

The --pretty=format:... option for git-log, etc has the annoying
property of giving you <unknown> instead of an empty string if an
item isn't example (say if you use %b on a commit with no body).

Am I missing some obvious solution here?  

Thanks,

Brian

```

## Jeff King, 2008-01-06 09:05

Subject: Re: something like git-for-each-ref's --format for commits?
Message-ID: <20080106090507.GA10965@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20080106090507.GA10965%40coredump.intra.peff.net
In-Reply-To: <20080106085221.GA1729@bulgaria.corp.google.com>

```
On Sun, Jan 06, 2008 at 12:52:21AM -0800, Brian Swetland wrote:

> The --pretty=format:... option for git-log, etc has the annoying
> property of giving you <unknown> instead of an empty string if an
> item isn't example (say if you use %b on a commit with no body).
> 
> Am I missing some obvious solution here?  

I think --pretty=format: is what you are looking for. The "<unknown>"
behavior is fixed in the upcoming v1.5.4 (you get the empty string for
your example).

-Peff

```
