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

Re: [PATCH 3/3] commit: pass author/committer info to hooks

From
Jeff King <peff@peff.net>
Date
Mar 12, 2012, 11:29 UTC
Message-ID
<20120312112921.GB12921@sigill.intra.peff.net>
In-Reply-To
<7vsjhfxuhh.fsf_-_@alter.siamese.dyndns.org>
On Sun, Mar 11, 2012 at 04:11:38AM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> However, when the command was reimplemented in C, the rewritten code
> was not very faithful to the original, and hooks stopped getting the
> authorship information given with "--author".  Fix this by exporting
> the necessary environment variables.
> [...]
>  * This is the last patch of the simpler of the two approaches, that
>    builds on top of the two common preparatory patches.  It uses setenv()
>    to directly affect the execution environment of "git commit" process,
>    which is closer to the original scripted Porcelain implementation.

FWIW, I like this approach better. It's simpler, and I think it is perfectly sane to define "--author" as "act as if the contents were in GIT_AUTHOR_*"[1]. We do the same thing already with "git --git-dir", "git --work-tree", and other variables, and it keeps the code simple by making the environment variable the definitive source.

-Peff
[1] Your approach is slightly more complex, in that it handles "-c"
    (which is a good thing). But I think the principle is the same.
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 13 in “Stop a git commit by a specific author using pre-commit hook”
  1. Adrian CornishMar 9, 2012
  2. Neal KreitzingerMar 10, 2012
  3. Junio C HamanoMar 10, 2012
  4. Neal KreitzingerMar 10, 2012
  5. Junio C HamanoMar 11, 2012
  6. 3/4 test: does pre-commit-hook learn authorship?Junio C Hamano, Mar 11, 2012
  7. Johannes SixtMar 11, 2012
  8. Junio C HamanoMar 11, 2012
  9. 3/4 ident.c: add split_ident_line() to parse formatted ident lineJunio C Hamano, Mar 11, 2012
  10. 3/3 commit: pass author/committer info to hooksJunio C Hamano, Mar 11, 2012
  11. Jeff KingMar 12, 2012
  12. 3/4 run_hook(): enhance the interface to pass arbitrary environmentJunio C Hamano, Mar 11, 2012
  13. 4/4 commit: pass author/committer info to hooksJunio C Hamano, Mar 11, 2012

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.