git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to share config and hooks ?
@ 2009-05-27 19:58 Christian Senkowski
  2009-05-27 20:11 ` Johannes Schindelin
  2009-05-28  5:54 ` David Aguilar
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Senkowski @ 2009-05-27 19:58 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

I am searching for a way to share 'config' and hooks/* automatically.
I'd like to change and commit them as normal files and every user
cloning this repo should get those.

One way might be a little wrapper-script for git-clone which looks if
repo/.gitconfig or repo/.githooks exist and copies then the files to
repo/.git/[...]

But I am searching for a way to do this without any additional scripts.

Does anyone have an idea ?
And what'd you say about implementing this (with a
yes-please-copy-the-found-files/no-leave-them-alone - question) directly
into the git-binary ?


-- 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 280 bytes --]

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

* Re: How to share config and hooks ?
  2009-05-27 19:58 How to share config and hooks ? Christian Senkowski
@ 2009-05-27 20:11 ` Johannes Schindelin
  2009-05-28  5:54 ` David Aguilar
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2009-05-27 20:11 UTC (permalink / raw)
  To: Christian Senkowski; +Cc: git

Hi,

On Wed, 27 May 2009, Christian Senkowski wrote:

> I am searching for a way to share 'config' and hooks/* automatically.
> I'd like to change and commit them as normal files and every user
> cloning this repo should get those.

For security reasons, both are not possible.

Why?  I am sure you can come up with a lot of evil scenarios if you let 
your evil side fantasize a little bit.

Ciao,
Dscho

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

* Re: How to share config and hooks ?
  2009-05-27 19:58 How to share config and hooks ? Christian Senkowski
  2009-05-27 20:11 ` Johannes Schindelin
@ 2009-05-28  5:54 ` David Aguilar
  1 sibling, 0 replies; 3+ messages in thread
From: David Aguilar @ 2009-05-28  5:54 UTC (permalink / raw)
  To: Christian Senkowski; +Cc: git

On Wed, May 27, 2009 at 09:58:04PM +0200, Christian Senkowski wrote:
> I am searching for a way to share 'config' and hooks/* automatically.
> I'd like to change and commit them as normal files and every user
> cloning this repo should get those.

Assuming you control your users' machines (such as in a company)
then you can simply add something like in:
/usr/share/git-core/templates/hooks/pre-commit

#!/bin/sh
for hook in /usr/share/git-hooks/pre-commit.d/*; do
	if ! $hook "$@"; then
		exit $?
	fi
fi

Just create a wrapper for each hook.

When you want to upgrade your hooks you just change the
"included" hooks in /usr/share/git-hooks/<hookname>.d/ and all
of your repos pick up the updated hooks since they reference
them indirectly.

Assuming you're using an apt or rpm infrastructure and you
control your users' machines, then this is easy.


If you're trying to do this generally for anybody who clones
your project (such as in the real world), then there's no way.


> One way might be a little wrapper-script for git-clone which looks if
> repo/.gitconfig or repo/.githooks exist and copies then the files to
> repo/.git/[...]
> But I am searching for a way to do this without any additional scripts.

You're looking for the git templates directory.  That's what
gets copied into each repository at git-init/git-clone time.
Again, only useful in a controlled environment where you
control your user's git install.

I mention the trick above because if you install normal hooks,
upgrading them is a pain because every repo has its own copy.
By adding indirection into the hooks you can upgrade the
hooks globally with little effort.  It's also neat because the
example allows you to install multiple hooks for the same
action.  e.g. the post-commit example above allows you to have
several hooks in the post-commit.d/ directory.


> And what'd you say about implementing this (with a
> yes-please-copy-the-found-files/no-leave-them-alone - question) directly
> into the git-binary ?

Nope, Dscho already mentioned the security implications.


Have fun,

-- 

	David

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

end of thread, other threads:[~2009-05-28  5:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-27 19:58 How to share config and hooks ? Christian Senkowski
2009-05-27 20:11 ` Johannes Schindelin
2009-05-28  5:54 ` David Aguilar

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).