git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: GPG signing for git commit?

From
Jeff King <peff@peff.net>
Date
Apr 21, 2009, 20:27 UTC
Message-ID
<20090421202711.GB12891@coredump.intra.peff.net>
In-Reply-To
<slrnguhj1o.usr.sitaramc@sitaramc.homelinux.net>
On Fri, Apr 17, 2009 at 06:36:40PM +0000, Sitaram Chamarty wrote:
Show 12 quoted lines
> On 2009-04-17, Jeff King <peff@peff.net> wrote:
> >> If you set GIT_COMMITTER_*, won't it change the SHA of the
> >> commit itself?  I always thought so...
> >
> > No. Pushing will never create a new commit, so there are no new SHA-1s
> > calculated. But the reflog entry will contain GIT_COMMITTER_*, and is a
> > simple text file.
> 
> cool -- I didn't know this.  Thanks!
> 
> One last question: where do you set it, in the pre-commit
> hook on the server?
No, for two reasons:
  1. The pre-commit hook is run when making a local commit. For pushing,
     you would want the pre-receive hook.
  2. Hooks are executed as child processes of receive-pack, so they
     can't impact the environment it sees.

I think you would need to intercept the call to receive-pack (e.g., by replacing it with a wrapper script), set the variables based on ssh keys used (or whatever criteria you want), and then exec receive-pack.

-Peff
Previous: Sitaram ChamartyNext: Nguyen Thai Ngoc Duy
Message 11 of 17 in “GPG signing for git commit?”
  1. Chow Loong JinApr 3, 2009
  2. Linus TorvaldsApr 3, 2009
  3. Sam VilainApr 6, 2009
  4. Robin H. JohnsonApr 15, 2009
  5. Shawn O. PearceApr 15, 2009
  6. Robin H. JohnsonApr 15, 2009
  7. Shawn O. PearceApr 16, 2009
  8. Sitaram ChamartyApr 17, 2009
  9. Jeff KingApr 17, 2009
  10. Sitaram ChamartyApr 17, 2009
  11. Jeff KingApr 21, 2009
  12. Nguyen Thai Ngoc DuyMay 7, 2009
  13. Robin H. JohnsonMay 8, 2009
  14. Nguyen Thai Ngoc DuyMay 10, 2009
  15. Nguyen Thai Ngoc DuyMay 11, 2009
  16. Jakub NarebskiApr 7, 2009
  17. Linus TorvaldsApr 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.