Reduce disk writes in post-compile triggers
[gitolite.git] / src / commands / symbolic-ref
blobb65c792900f2712e7dafe835b2651eb44246dc93
1 #!/bin/sh
3 # Usage: ssh git@host symbolic-ref <repo> <arguments to git-symbolic-ref>
5 # allow 'git symbolic-ref' over a gitolite connection
7 # Security: remember all arguments to commands must match a very conservative
8 # pattern. Once that is assured, the symbolic-ref command has no security
9 # related side-effects, so we don't check arguments at all.
11 # Note: because of the restriction on allowed characters in arguments, you
12 # can't supply an arbitrary string to the '-m' option. The simplest
13 # work-around is-to-just-use-join-up-words-like-this if you feel the need to
14 # supply a "reason" string. In any case this is useless by default; you'd
15 # have to have core.logAllRefUpdates set for it to have any meaning.
17 die() { echo "$@" >&2; exit 1; }
18 usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
19 [ -z "$1" ] && usage
20 [ "$1" = "-h" ] && usage
21 [ -z "$GL_USER" ] && die GL_USER not set
23 # ----------------------------------------------------------------------
24 repo=$1; shift
25 repo=${repo%.git}
26 gitolite access -q "$repo" $GL_USER W any || die You are not authorised
28 # change head
29 cd $GL_REPO_BASE/$repo.git
31 git symbolic-ref "$@"