Run post-receive as the file owner

It's possible to run the git hook as user puppet, but anther user could
push as root and this will create files with owner root. The next user
could push again as puppet and get errors. After some discussion in
https://github.com/theforeman/puppet-puppet/pull/30 a conclusion was
reached that it's desired to run the hook as the file owner.

This patch adds setuid like behavior. It checks if we're running as a
different user than the file owner and root if that user is root. If so
we change the uid to the file owner.