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

Re: global hooks - once again

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 2, 2010, 19:18 UTC
Message-ID
<7v630x1yl8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTikXJS5QCXMXgsOfkYn9cMBQV6o23tds5YG3A_OI@mail.gmail.com>
Eugene Sajine <euguess@gmail.com> writes:
> For example, so i could say
> $ git config --global hooks.dir ~/git/hooks

I don't think "global" hooks are useful for people who work on more than one project, or people who interact in more than one ways to projects. Different projects typically have different needs out of the hooks (e.g. pre-commit policy), and different workflows typically call for different needs out of the hooks (e.g. I would want to be able to rebase in my private working repository but not in the repository I use for integration of other people's branches).

So I am fairly negative on your particular example above.

But it is understandable for one to use more than one repository for the same project and use them in the same way; in such a case, I agree that a way to ensure that these repositories use the same set of hooks (and non-hooks, e.g. commit templates, local ignore pattern files, etc.) is desirable.

So I would imagine that your example without "--global" would be a reasonable thing to do once per repository.

Now, as long as the "do once per repository" action that you need to do is simple enough, it doesn't necessarily have to be "git config". Perhaps

    [alias]
    set-hooks = !"sh -c 'rm -fr .git/hooks && ln -s $1 .git/hooks' -"

could also be a simple single-command solution that is "do once per repository".

Can't we do better and make this "do nunce per repository" instead?

You first have to think how you are creating these more-than-one repositories you would want to make sure they use the same hooks. For example, do you have a single "upstream" repository and everything is a clone of it? If so, perhaps a way to tell "clone" via $HOME/.gitconfig that when cloning from a particular URL you would want to run a particular post-clone script might be a better way.

Previous: Eugene SajineNext: Eugene Sajine
Message 4 of 14 in “global hooks - once again”
  1. Eugene SajineJul 2, 2010
  2. Jonathan NiederJul 2, 2010
  3. Eugene SajineJul 2, 2010
  4. Junio C HamanoJul 2, 2010
  5. Eugene SajineJul 2, 2010
  6. Peter KjellerstedtJul 5, 2010
  7. Alex RiesenJul 6, 2010
  8. Eugene SajineJul 6, 2010
  9. Peter KjellerstedtJul 6, 2010
  10. demerphqJul 6, 2010
  11. Eugene SajineJul 6, 2010
  12. Eugene SajineJul 6, 2010
  13. demerphqJul 6, 2010
  14. Jonathan NiederJul 2, 2010

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.