update with some gotchas about how git calls hooks

This commit is contained in:
Joey Hess 2013-08-24 12:09:21 -04:00
parent ed054c11af
commit d9b8bc0769

View file

@ -20,12 +20,34 @@ Here's how I set it up. --[[Joey]]
7. Instruct advanced users to clone a http url that ends with the "/.git/" 7. Instruct advanced users to clone a http url that ends with the "/.git/"
directory. For example, for downloads.kitenet.net, the clone url directory. For example, for downloads.kitenet.net, the clone url
is `https://downloads.kitenet.net/.git/` is `https://downloads.kitenet.net/.git/`
8. Set up a git `post-receive` hook that runs `git annex merge`, and 8. Set up a git `post-receive` hook to update the repository's working tree
the repository's working tree will automatically be updated when when changes are pushed to it. See below for details.
you run `git annex sync` in a clone that can push to the repository.
(Needs git-annex version 4.20130703 or newer; older versions
can use `git annex sync` in the post-receive hook instead.)
When users clone over http, and run git-annex, it will When users clone over http, and run git-annex, it will
automatically learn all about your repository and be able to download files automatically learn all about your repository and be able to download files
right out of it, also using http. right out of it, also using http.
## post-receive hook
If you have git-annex 4.20130703, the post-receive hook mentioned above
in step 8 just needs to run `git annex merge`.
With older versions of git-annex, you can instead use `git annex sync`.
There are two gotchas with some versions of git to be aware of when writing
this post-receive hook.
1. The hook may be run with the current directory set to the `.git`
directory, and not the top of your work tree. So you need to `cd ..` or
similar in the hook.
2. `GIT_DIR` may be set to `.`, which will not be right after changing
directory. So you will probably want to unset it.
Here's a post-receive hook that takes these problems into account:
<pre>
#!/bin/sh
unset GIT_DIR
cd ..
git annex merge
</pre>