RichiH/vcsh — pull request #19 by vdemeester (2012-01-08 15:47:28+00:00)
Title: Hook support

Hi,

This is a try of hook support implementation for vcsh. It is still a bit dirty and I just add hook entry point I needed.
Basically, hook entry points are define with `run_hook {somename}` function. It will try to load hooks from the `${VCSH_HOOK_D}/${somename}` folder if present. Only the ones that have an executable bit will be sourced. The hook are stored by default in `$XDG_CONFIG_HOME/vcsh/hook.d`.

I needed this on my vcsh-home powered machine as almost all of my vcsh managed repositories have a README file (README.md actually) ; this caused conflicts. Thus, I'm using sparseCheckout stuff (available from git >= 1.7.0) -> [git-read-tree](http://linux.die.net/man/1/git-read-tree).
With this modifications, I just have to create a `$XDG_CONFIG_HOME/vcsh/hook.d/init/sparseCheckout` file with the following content, and make it executable, to get it work.

```sh
if ! test -d "$(git config core.sparseCheckout)" = "true"; then
git config core.sparseCheckout true
fi
if ! test -e "$GIT_DIR/info/sparse-checkout"; then
cat > $GIT_DIR/info/sparse-checkout << EOF
*
!README
!README.md
EOF
fi
```

I'm not sure there was a better way to solve my use case, but I tried that. It might be useful for others use cases, but… don't know.

Feel free to merge it, throw it away (by closing this pull request) or asking anything :-)

NB : I didn't want to insert space in place of tab (as my editors is configured to insert space only) so I added a vim special line at the end of vcsh.