views:

9

answers:

1

I'm trying to do this:

git show --format=format:"parents:%p%ncommit:%h%nauthor:%an%n%N%n%s%n%b" -C; echo

in my hooks.showrev in my post-receive-email script for git:

custom_showrev=$(git config hooks.showrev || git show --format=oneline --abbrev-commit -C %s; echo)

using the "standard" post-receive-email script. It just gives me the following error:

remote: /home/git/git-core/contrib/hooks/post-receive-email: line 631: parents:0937024: command not found

when I commit with git from the console. Line 631 has:

            eval $(printf "$custom_showrev" $onerev)

Anyone have any idea what I'm doing wrong here?

Specifically, my question is, how do you use a custom format with the post-receive-email hook?

A: 

The problem is with

eval $(printf "$custom_showrev" $onerev)

the printf tries to take the format string and insert $onerev at one of the % spots and then eval everything.

Simply replace the eval line with the line:

git show --format=format:"parents:%p%ncommit:%h%nauthor:%an%n%N%n%s%n%b" -C $onerev

and it will work.

cmcculloh
Probably better to us %cn for commit author instead of %an (which I believe represents the person who started the branch)
cmcculloh