Fix the calls to pre- and post-receive custom hooks

- Reset G_ID if the custom pre-receive hook fails
- Use a pipe to feed stdin to the custom pre- and post-receive
  hooks, in the same way that the standalone git works