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

Re: [PATCH 1/4] hooks: Add function to check if a hook exists

From
Aaron Schrab <aaron@schrab.com>
Date
Dec 29, 2012, 14:50 UTC
Message-ID
<20121229145032.GB3789@pug.qqx.org>
In-Reply-To
<7vwqw1fw5a.fsf@alter.siamese.dyndns.org>
At 18:08 -0800 28 Dec 2012, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>Aaron Schrab <aaron@schrab.com> writes:
>
>> Create find_hook() function to determine if a given hook exists and is
>> executable.  If it is the path to the script will be returned, otherwise
>> NULL is returned.
>
>Sounds like a sensible thing to do.  To make sure the API is also
>sensible, all the existing hooks should be updated to use this API,
>no?

I'd been trying to keep the changes limited. I'll see about modifying the existing places that run hooks in v2 of the series.

Show 16 quoted lines
>> This is in support for an upcoming run_hook_argv() function which will
>> expect the full path to the hook script as the first element in the
>> argv_array.
>
>There is currently a public function called run_hook() that squats
>on the good name with a kludgy API that is too specific to using
>separate index file.  Back when it was a private helper in the
>implementation of "git commit", it was perfectly fine, but it was
>exported without giving much thought on the API.
>
>If you are introducing a new run_hook_* function, give it a generic
>enough API that lets all the existing hook callers to use it.  I
>would imagine that the API requirement may be modelled after
>run_command() API so that we can pass argv[] and tweak the hook's
>environ[], as well as feeding its stdin and possibly reading from
>its stdout.  That would be very useful.

I think the attraction of the run_hook() API is its simplicity. It's currently a fairly thin wrapper around the run_command() API. I suspect that if the run_hook() API were made generic enough to support all of the existing hook callers it would greatly complicate the existing calls to run_hook() while not providing much benefit to hook callers which can't currently use it beyond what run_command() offers.

Since I'm going to be changing the interface for this hook in v2 of the series so that it will be more complicated than can be readily addressed with the run_hook() API (and will have use a fixed number of arguments anyway) I'll be dropping the run_hook_argv() function.

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 22 in “pre-push hook support”
  1. 0/4 pre-push hook supportAaron Schrab, Dec 28, 2012
  2. 1/4 hooks: Add function to check if a hook existsAaron Schrab, Dec 28, 2012
  3. Junio C HamanoDec 29, 2012
  4. Aaron SchrabDec 29, 2012
  5. Junio C HamanoDec 29, 2012
  6. 2/4 hooks: support variable number of parametersAaron Schrab, Dec 28, 2012
  7. 3/4 push: Add support for pre-push hooksAaron Schrab, Dec 28, 2012
  8. 4/4 Add sample pre-push hook scriptAaron Schrab, Dec 28, 2012
  9. Junio C HamanoDec 29, 2012
  10. Aaron SchrabDec 29, 2012
  11. Junio C HamanoDec 29, 2012
  12. 0/3 pre-push hook supportAaron Schrab, Jan 13, 2013
  13. 1/3 hooks: Add function to check if a hook existsAaron Schrab, Jan 13, 2013
  14. 2/3 push: Add support for pre-push hooksAaron Schrab, Jan 13, 2013
  15. Junio C HamanoJan 14, 2013
  16. Junio C HamanoJan 15, 2013
  17. Junio C HamanoJan 15, 2013
  18. 3/3 Add sample pre-push hook scriptAaron Schrab, Jan 13, 2013
  19. Junio C HamanoJan 14, 2013
  20. Junio C HamanoJan 14, 2013
  21. Junio C HamanoJan 14, 2013
  22. Junio C HamanoJan 15, 2013

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.