git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* global hooks
@ 2008-03-19 16:04 Victor Bogado da Silva Lins
  2008-03-20  1:04 ` Jonathan del Strother
  2008-03-20  2:25 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Victor Bogado da Silva Lins @ 2008-03-19 16:04 UTC (permalink / raw)
  To: git

Hi, I made a prepare-commit-msg hook today, it basically appends the
diff I am about to commit to the commented information that normally
appears. 

The problem is that if I want this hook in all projects I have, I have
to copy that file to every single project I have. This is an error prone
operation, not to mention a pain in the... .

SO my question is, is there a way to make that hook global to all
projects? If not, would it be a good idea to allow this?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: global hooks
  2008-03-19 16:04 global hooks Victor Bogado da Silva Lins
@ 2008-03-20  1:04 ` Jonathan del Strother
  2008-03-20  2:25 ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan del Strother @ 2008-03-20  1:04 UTC (permalink / raw)
  To: Victor Bogado da Silva Lins; +Cc: git

On Wed, Mar 19, 2008 at 4:04 PM, Victor Bogado da Silva Lins
<victor@bogado.net> wrote:
> Hi, I made a prepare-commit-msg hook today, it basically appends the
>  diff I am about to commit to the commented information that normally
>  appears.
>
>  The problem is that if I want this hook in all projects I have, I have
>  to copy that file to every single project I have. This is an error prone
>  operation, not to mention a pain in the... .
>
>  SO my question is, is there a way to make that hook global to all
>  projects? If not, would it be a good idea to allow this?

I'd love to see something along these lines - at the moment, I have a
precommit hook to drop textmate's caret metadata from the commit file,
and it's a pain having to symlink it into every git repo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: global hooks
  2008-03-19 16:04 global hooks Victor Bogado da Silva Lins
  2008-03-20  1:04 ` Jonathan del Strother
@ 2008-03-20  2:25 ` Junio C Hamano
  2008-03-20 11:20   ` Johan Herland
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2008-03-20  2:25 UTC (permalink / raw)
  To: Victor Bogado da Silva Lins; +Cc: git

Victor Bogado da Silva Lins <victor@bogado.net> writes:

> SO my question is, is there a way to make that hook global to all
> projects? If not, would it be a good idea to allow this?

Probably a post- git-init hook that lets you do anything to your newly
created repository would be the only thing that you need.  Then you can
copy, untar or even use symlink to muck with .git/hooks/ in whatever way
you please.

There needs a mechanism for you to specify what that hook is, and it
cannot be in individual repositories, so it has to live in ~/.gitconfig
somewhere.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: global hooks
  2008-03-20  2:25 ` Junio C Hamano
@ 2008-03-20 11:20   ` Johan Herland
  2008-03-20 12:26     ` Ping Yin
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Herland @ 2008-03-20 11:20 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Victor Bogado da Silva Lins

On Thursday 20 March 2008, Junio C Hamano wrote:
> Victor Bogado da Silva Lins <victor@bogado.net> writes:
> 
> > SO my question is, is there a way to make that hook global to all
> > projects? If not, would it be a good idea to allow this?
> 
> Probably a post- git-init hook that lets you do anything to your newly
> created repository would be the only thing that you need.  Then you can
> copy, untar or even use symlink to muck with .git/hooks/ in whatever way
> you please.
> 
> There needs a mechanism for you to specify what that hook is, and it
> cannot be in individual repositories, so it has to live in ~/.gitconfig
> somewhere.

Or you could add the hook (either the post-init hook, or for that matter
the hook you want to make global) to the Git template directory on your
system (/usr/share/git-core/templates by default). If you don't want to
make it system-global (only user-global), I guess you could make your
own Git template directory somewhere (copy the system's template dir,
and add/enable whatever hooks you like), and set up an alias to
"git init --template=<your_template_dir>". Then use this alias instead
of "git init".


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: global hooks
  2008-03-20 11:20   ` Johan Herland
@ 2008-03-20 12:26     ` Ping Yin
  2008-03-20 12:56       ` Johan Herland
  0 siblings, 1 reply; 6+ messages in thread
From: Ping Yin @ 2008-03-20 12:26 UTC (permalink / raw)
  To: Johan Herland; +Cc: git, Junio C Hamano, Victor Bogado da Silva Lins

On Thu, Mar 20, 2008 at 7:20 PM, Johan Herland <johan@herland.net> wrote:
> On Thursday 20 March 2008, Junio C Hamano wrote:
>  > Victor Bogado da Silva Lins <victor@bogado.net> writes:
>  >
>  > > SO my question is, is there a way to make that hook global to all
>  > > projects? If not, would it be a good idea to allow this?
>  >
>  > Probably a post- git-init hook that lets you do anything to your newly
>  > created repository would be the only thing that you need.  Then you can
>  > copy, untar or even use symlink to muck with .git/hooks/ in whatever way
>  > you please.
>  >
>  > There needs a mechanism for you to specify what that hook is, and it
>  > cannot be in individual repositories, so it has to live in ~/.gitconfig
>  > somewhere.
>
>  Or you could add the hook (either the post-init hook, or for that matter
>  the hook you want to make global) to the Git template directory on your
>  system (/usr/share/git-core/templates by default). If you don't want to
>  make it system-global (only user-global), I guess you could make your
>  own Git template directory somewhere (copy the system's template dir,
>  and add/enable whatever hooks you like), and set up an alias to
>  "git init --template=<your_template_dir>". Then use this alias instead
>  of "git init".
>

template dir is meaningful for static hooks. However, sometimes we
need dynamic hooks which change over time. Having a real global hook
can help to implement a single logic or policy spreading among
multiple repositories.

For example, we can enfore a policy to help to update the test or
deploy environent automatically: when repositories are pushed into a
central place, they are checked out into different places or hosts
automatically.

I think ~/.gitconfig is a good place to give such an entry point.



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: global hooks
  2008-03-20 12:26     ` Ping Yin
@ 2008-03-20 12:56       ` Johan Herland
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Herland @ 2008-03-20 12:56 UTC (permalink / raw)
  To: Ping Yin; +Cc: git, Junio C Hamano, Victor Bogado da Silva Lins

On Thursday 20 March 2008, Ping Yin wrote:
> On Thu, Mar 20, 2008 at 7:20 PM, Johan Herland <johan@herland.net> wrote:
> > On Thursday 20 March 2008, Junio C Hamano wrote:
> >  > Victor Bogado da Silva Lins <victor@bogado.net> writes:
> >  > > SO my question is, is there a way to make that hook global to all
> >  > > projects? If not, would it be a good idea to allow this?
> >  >
> >  > Probably a post- git-init hook that lets you do anything to your newly
> >  > created repository would be the only thing that you need.  Then you can
> >  > copy, untar or even use symlink to muck with .git/hooks/ in whatever way
> >  > you please.
> >  >
> >  > There needs a mechanism for you to specify what that hook is, and it
> >  > cannot be in individual repositories, so it has to live in ~/.gitconfig
> >  > somewhere.
> >
> >  Or you could add the hook (either the post-init hook, or for that matter
> >  the hook you want to make global) to the Git template directory on your
> >  system (/usr/share/git-core/templates by default). If you don't want to
> >  make it system-global (only user-global), I guess you could make your
> >  own Git template directory somewhere (copy the system's template dir,
> >  and add/enable whatever hooks you like), and set up an alias to
> >  "git init --template=<your_template_dir>". Then use this alias instead
> >  of "git init".
> 
> template dir is meaningful for static hooks. However, sometimes we
> need dynamic hooks which change over time. Having a real global hook
> can help to implement a single logic or policy spreading among
> multiple repositories.

If you need to centralize the logic, you can just keep the actual hook
outside the template directory, and store an (absolute) symlink within
the template dir pointing to the hook. All your git repos will now
exercise the centralized hook instead of each having a separate copy.

> For example, we can enfore a policy to help to update the test or
> deploy environent automatically: when repositories are pushed into a
> central place, they are checked out into different places or hosts
> automatically.
> 
> I think ~/.gitconfig is a good place to give such an entry point.

Still, I think this can be solved with the existing tools, without
adding more features and config directives.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-03-20 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-19 16:04 global hooks Victor Bogado da Silva Lins
2008-03-20  1:04 ` Jonathan del Strother
2008-03-20  2:25 ` Junio C Hamano
2008-03-20 11:20   ` Johan Herland
2008-03-20 12:26     ` Ping Yin
2008-03-20 12:56       ` Johan Herland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).