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

Re: StGit hooks

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 28, 2007, 19:31 UTC
Message-ID
<7vfxyq5fr7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20071128172152.GB21310@diana.vm.bytemark.co.uk>
Karl Hasselström <kha@treskal.com> writes:
Show 16 quoted lines
> On 2007-11-28 18:06:36 +0100, Andreas Ericsson wrote:
>
>> True, but there are ways of figuring out which branch you're on,
>> using the arguments passed to the hook.
>>
>> The rebase hook (which is where this discussion started) gets the
>> branches passed to "git rebase" as arguments. Figuring out if either
>> of those branches are actually under stgit control shouldn't be
>> overly tricky for one so familiar with stgit as yourself.
>
> No, that part is trivial. The hard part is not messing up the user's
> existing hook scripts.
>
> If I do go ahead and do this, I have a feeling I'll be beefing up
> git's hook dispatch mechanism first -- if I can get it past Junio,
> obviously. :-)
I do not see a fundamental problem in a scheme like this:
 * when running a hook $foo, if .git/hooks/$foo.d/. does not exist, we
   operate as we have always done.
 * if .git/hooks/$foo.d/ exists, we readdir(3) it and run the hooks found
   in the order their names sort bytewise (similar to /etc/rc$n.d/).
   - when the purpose of the $foo hook is to return a bool to refuse an
     operation, stop at the first failure;
   - when the purpose of the $foo hook is to cause effect, run them all
     in series.
 * When .git/hooks/$foo.d/ exists, there will always be "050-simple" in
   that directory.  It checks if .git/hooks/$foo exists and sources it
   if it does.  A custom hook that wants to run before or after it can
   be named NNN-mine in .git/hooks/$foo.d/, where NNN sorts earlier or
   later than 050 to define the execution order.

We probably would want to reserve a special exit code for the hooks run for their effects so that they can signal "I do not want you to run the remainder".

Previous: Karl HasselströmNext: Jon Smirl
Message 16 of 26 in “stgit: lost all my patches again”
  1. Jon SmirlNov 27, 2007
  2. Jakub NarebskiNov 27, 2007
  3. Jon SmirlNov 27, 2007
  4. Karl HasselströmNov 28, 2007
  5. StGit hooksKarl Hasselström, Nov 28, 2007
  6. Andreas EricssonNov 28, 2007
  7. Karl HasselströmNov 28, 2007
  8. Andreas EricssonNov 28, 2007
  9. Karl HasselströmNov 28, 2007
  10. Andreas EricssonNov 28, 2007
  11. Jon SmirlNov 28, 2007
  12. Andreas EricssonNov 28, 2007
  13. Karl HasselströmNov 28, 2007
  14. Andreas EricssonNov 28, 2007
  15. Karl HasselströmNov 28, 2007
  16. Junio C HamanoNov 28, 2007
  17. Jon SmirlNov 28, 2007
  18. Karl HasselströmNov 28, 2007
  19. Jon SmirlNov 28, 2007
  20. Karl HasselströmNov 28, 2007
  21. Jon SmirlNov 28, 2007
  22. Karl HasselströmNov 28, 2007
  23. Make "stg repair" help text more helpfulKarl Hasselström, Nov 30, 2007
  24. Junio C HamanoNov 28, 2007
  25. Jon SmirlNov 28, 2007
  26. Karl HasselströmNov 28, 2007

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.