Test commit
[cogito/jonas.git] / contrib / push-update.sh
blob8b94ccf2f6187756c897e7ee41692505d6c05184
1 #!/bin/sh
3 # Automatically update working copy of target repository when pushing
4 # Copyright (c) Petr Baudis, 2006
6 # Sometimes you might want to push to a repository with a working copy
7 # attached. That is certainly possible and if you push into a branch that
8 # is not checked out at the remote side (e.g. if you push into 'origin'
9 # in the standard setup created by `cg-clone` when you have 'master' checked
10 # out and 'origin' represents the remote repository), it works just fine.
12 # HOWEVER, if you push to the same branch as your current branch (usually
13 # 'master'), you will get into very big problems since Cogito will think your
14 # working copy suddenly corresponds to the pushed revision, however the
15 # working copy was not updated yet and still represents the original revision.
16 # If you run e.g. `cg-diff` then, you will get very funny results. This hook
17 # script can be used to update your remote working copy every time you push.
19 # Note that you should be careful while deploying this, it can get very
20 # confusing especially if someone else pushes to your working repository
21 # in the middle of your work. If you work in a team, you should either
22 # use a central repository set up using `cg-admin-setuprepo` or fetch from
23 # each other, not push into someone else's repository.
25 # Also, it is inherently racy and you can end up in an inconsistent state
26 # in case things go bad enough.
28 # This is designed to run as Git update hook. Add this to your
29 # '.git/hooks/update':
31 # /path/to/push-update.sh "$@"
33 # and do not forget to make the hook executable.
35 # It is totally untested, in case you care. :P
37 cd ..
38 if [ "$(git-symbolic-ref HEAD)" == "$1" ]; then
39 _cg_orig_head="$2" cg-merge "$3"