[PATCH/RFC] Add post-init hook

This adds a configuration variable 'init.post-init-file', to supply a path to a script that will be run
following git-init (and thus also git-clone).

Signed-off-by: Jonathan del Strother <jon.delStrother <at> bestbefore.tv>
---

I have a number of hooks that I have to install every time I create/clone a repository.  This patch adds a
post-init hook that's perfect for setting up that sort of stuff.
It's my first git patch that does much C work (even if it was mostly a cut & paste job) - comments would be welcome.

 Documentation/config.txt   |    4 ++++
 Documentation/git-init.txt |    7 +++++++
 builtin-init-db.c          |   36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index bbe38cc..746d663 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -881,6 +881,10 @@ i18n.logOutputEncoding::
 	Character encoding the commit messages are converted to when
 	running 'git-log' and friends.

+init.post-init-file::
+	A path to a script to run on the initialization of any git
+	repository.
+
 instaweb.browser::
 	Specify the program that will be used to browse your working
 	repository in gitweb. See linkgit:git-instaweb[1].
(Continue reading)

Jeff King | 8 Oct 03:53

Re: [PATCH/RFC] Add post-init hook

On Wed, Oct 08, 2008 at 12:10:33AM +0100, Jonathan del Strother wrote:

> I have a number of hooks that I have to install every time I
> create/clone a repository.  This patch adds a post-init hook that's
> perfect for setting up that sort of stuff.

Why is the --template parameter to clone and init not sufficient?

-Peff

Re: [PATCH/RFC] Add post-init hook

On Wed, Oct 8, 2008 at 2:53 AM, Jeff King <peff <at> peff.net> wrote:
> On Wed, Oct 08, 2008 at 12:10:33AM +0100, Jonathan del Strother wrote:
>
>> I have a number of hooks that I have to install every time I
>> create/clone a repository.  This patch adds a post-init hook that's
>> perfect for setting up that sort of stuff.
>
> Why is the --template parameter to clone and init not sufficient?
>
 Partly that I never remember to include the --template parameter,
partly that I wanted to customize its behaviour (it copies the files,
I want symlinks so I only have to edit my hooks in one place whenever
I change them)
Jeff King | 9 Oct 03:41

Re: [PATCH/RFC] Add post-init hook

On Wed, Oct 08, 2008 at 09:16:56AM +0100, Jonathan del Strother wrote:

> > Why is the --template parameter to clone and init not sufficient?
> >
>  Partly that I never remember to include the --template parameter,

In that case, I would think a core.template parameter might make more
sense.

> partly that I wanted to customize its behaviour (it copies the files,
> I want symlinks so I only have to edit my hooks in one place whenever
> I change them)

This makes a lot of sense to me as a best-practice. I wonder if we
wouldn't do better to add a core.symlink-templates option?

-Peff
Junio C Hamano | 9 Oct 13:24
Favicon
Gravatar

Re: [PATCH/RFC] Add post-init hook

Jeff King <peff <at> peff.net> writes:

> On Wed, Oct 08, 2008 at 09:16:56AM +0100, Jonathan del Strother wrote:
> ...
>> I want symlinks so I only have to edit my hooks in one place whenever
>> I change them)
>
> This makes a lot of sense to me as a best-practice. I wonder if we
> wouldn't do better to add a core.symlink-templates option?

AFAIR, "git init" copies symlinks in templates as symlinks, so I do not
see why you would even want to have such an option.

Wouldn't it be better if users and installations with such a special
set of templates specified by core.template or --template prepare a
template directory with files and symbolic links of their liking?  If
they want some hooks to point at the latest copy of installation specific
standard hook script, templates/hooks/$that_hook can be a symlink to the
real location, no?
Jeff King | 9 Oct 13:32

Re: [PATCH/RFC] Add post-init hook

On Thu, Oct 09, 2008 at 04:24:29AM -0700, Junio C Hamano wrote:

> > This makes a lot of sense to me as a best-practice. I wonder if we
> > wouldn't do better to add a core.symlink-templates option?
> 
> AFAIR, "git init" copies symlinks in templates as symlinks, so I do not
> see why you would even want to have such an option.

Ah, I didn't realize that. In that case, yes, setting up a template
directory of symlinks makes the most sense. I think a core.template
option is still worthwhile, though.

-Peff
Alex Riesen | 9 Oct 13:34

Re: [PATCH/RFC] Add post-init hook

2008/10/9 Junio C Hamano <gitster <at> pobox.com>:
> Jeff King <peff <at> peff.net> writes:
>> On Wed, Oct 08, 2008 at 09:16:56AM +0100, Jonathan del Strother wrote:
>> ...
>>> I want symlinks so I only have to edit my hooks in one place whenever
>>> I change them)
>>
>> This makes a lot of sense to me as a best-practice. I wonder if we
>> wouldn't do better to add a core.symlink-templates option?
>
> AFAIR, "git init" copies symlinks in templates as symlinks, so I do not
> see why you would even want to have such an option.
>
> Wouldn't it be better if users and installations with such a special
> set of templates specified by core.template or --template prepare a
> template directory with files and symbolic links of their liking?  If
> they want some hooks to point at the latest copy of installation specific
> standard hook script, templates/hooks/$that_hook can be a symlink to the
> real location, no?

It will be replaced with a file next time you update your git installation.
Seems like we need ~/.gitconfig/*...

Gmane