git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Christian Senkowski <csenkowski@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: How to share config and hooks ?
Date: Wed, 27 May 2009 22:54:18 -0700	[thread overview]
Message-ID: <20090528055417.GA21329@gmail.com> (raw)
In-Reply-To: <4A1D9B4C.7030504@gmx.de>

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

      parent reply	other threads:[~2009-05-28  5:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090528055417.GA21329@gmail.com \
    --to=davvid@gmail.com \
    --cc=csenkowski@gmx.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).