tags:

views:

49

answers:

1

I'd like to parse metainformations from git repository. I'd like to fetch a single information for a commit, as in

git log --pretty=format:%an HEAD^..HEAD

Problem is, this is not working for the first commit in repository.

git show --pretty=format:%an HEAD^..HEAD

is also close to what I want, except I'm not interested in parsing actual diff.

Any idea how to make git log work for the first commit or how to disable git show from showing commit content?

Or, is there any better way how to retrieve metadata about given commit?

+5  A: 

Supply the quiet option to show to suppress the diff.

git show --quiet HEAD

So for your example, author name:

git show --quiet --pretty=format:%an
Charles Bailey
Missed that in docs, thanks!
Almad
Don't feel bad; it's not in the docs. (the docs cop-out, saying "This manual page describes only the most frequently used options.")
Derek