Re: How to share config and hooks ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]