{"thread":{"id":"19540","subject":"How to share config and hooks ?","startedAt":"2009-05-27T19:58:04Z","lastAt":"2009-05-28T05:54:18Z","messageCount":3,"participants":["Christian Senkowski","Johannes Schindelin","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114831","messageId":"4A1D9B4C.7030504@gmx.de","threadId":"19540","inReplyTo":null,"subject":"How to share config and hooks ?","fromName":"Christian Senkowski","fromEmail":"csenkowski@gmx.de","sentAt":"2009-05-27T19:58:04Z","receivedAt":"2009-05-27T19:58:04Z","isPatch":false,"sender":{"key":"csenkowski@gmx.de","avatar":null},"body":"I am searching for a way to share 'config' and hooks/* automatically.\nI'd like to change and commit them as normal files and every user\ncloning this repo should get those.\n\nOne way might be a little wrapper-script for git-clone which looks if\nrepo/.gitconfig or repo/.githooks exist and copies then the files to\nrepo/.git/[...]\n\nBut I am searching for a way to do this without any additional scripts.\n\nDoes anyone have an idea ?\nAnd what'd you say about implementing this (with a\nyes-please-copy-the-found-files/no-leave-them-alone - question) directly\ninto the git-binary ?\n\n\n-- \n\n"},{"id":"114832","messageId":"alpine.DEB.1.00.0905272209480.26154@pacific.mpi-cbg.de","threadId":"19540","inReplyTo":"4A1D9B4C.7030504@gmx.de","subject":"Re: How to share config and hooks ?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-05-27T20:11:12Z","receivedAt":"2009-05-27T20:11:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 27 May 2009, Christian Senkowski wrote:\n\n> I am searching for a way to share 'config' and hooks/* automatically.\n> I'd like to change and commit them as normal files and every user\n> cloning this repo should get those.\n\nFor security reasons, both are not possible.\n\nWhy?  I am sure you can come up with a lot of evil scenarios if you let \nyour evil side fantasize a little bit.\n\nCiao,\nDscho\n"},{"id":"114885","messageId":"20090528055417.GA21329@gmail.com","threadId":"19540","inReplyTo":"4A1D9B4C.7030504@gmx.de","subject":"Re: How to share config and hooks ?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-28T05:54:18Z","receivedAt":"2009-05-28T05:54:18Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, May 27, 2009 at 09:58:04PM +0200, Christian Senkowski wrote:\n> I am searching for a way to share 'config' and hooks/* automatically.\n> I'd like to change and commit them as normal files and every user\n> cloning this repo should get those.\n\nAssuming you control your users' machines (such as in a company)\nthen you can simply add something like in:\n/usr/share/git-core/templates/hooks/pre-commit\n\n#!/bin/sh\nfor hook in /usr/share/git-hooks/pre-commit.d/*; do\n\tif ! $hook \"$@\"; then\n\t\texit $?\n\tfi\nfi\n\nJust create a wrapper for each hook.\n\nWhen you want to upgrade your hooks you just change the\n\"included\" hooks in /usr/share/git-hooks/<hookname>.d/ and all\nof your repos pick up the updated hooks since they reference\nthem indirectly.\n\nAssuming you're using an apt or rpm infrastructure and you\ncontrol your users' machines, then this is easy.\n\n\nIf you're trying to do this generally for anybody who clones\nyour project (such as in the real world), then there's no way.\n\n\n> One way might be a little wrapper-script for git-clone which looks if\n> repo/.gitconfig or repo/.githooks exist and copies then the files to\n> repo/.git/[...]\n> But I am searching for a way to do this without any additional scripts.\n\nYou're looking for the git templates directory.  That's what\ngets copied into each repository at git-init/git-clone time.\nAgain, only useful in a controlled environment where you\ncontrol your user's git install.\n\nI mention the trick above because if you install normal hooks,\nupgrading them is a pain because every repo has its own copy.\nBy adding indirection into the hooks you can upgrade the\nhooks globally with little effort.  It's also neat because the\nexample allows you to install multiple hooks for the same\naction.  e.g. the post-commit example above allows you to have\nseveral hooks in the post-commit.d/ directory.\n\n\n> And what'd you say about implementing this (with a\n> yes-please-copy-the-found-files/no-leave-them-alone - question) directly\n> into the git-binary ?\n\nNope, Dscho already mentioned the security implications.\n\n\nHave fun,\n\n-- \n\n\tDavid\n"}]}