How to share config and hooks ?

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

How to share config and hooks ?

From: Christian Senkowski <hidden>
Date: 2016-06-15 22:46:51

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 ?


-- 

Re: How to share config and hooks ?

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:46:51

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

Re: How to share config and hooks ?

From: David Aguilar <hidden>
Date: 2016-06-15 22:46:52

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help