'symbolic-ref' ADC replaces and obsoletes 'set-head'

set-head was too specific.  See comments in symbolic-ref for more on
this ADC, but basically it lets you run 'git symbolic-ref' on a repo
that you have write access to.

(in response to http://comments.gmane.org/gmane.comp.version-control.git/182067)
This commit is contained in:
Sitaram Chamarty 2011-09-26 18:15:57 +05:30
parent 6efea9d7a3
commit a2fd597c51
2 changed files with 33 additions and 17 deletions

View file

@ -1,17 +0,0 @@
#!/bin/sh
. $(dirname $0)/adc.common-functions
[ -z "$GL_RC" ] && die "ENV GL_RC not set"
[ -z "$2" ] && die "usage: set-head /path/to/repo.git refs/heads/branchname"
get_rights_and_owner $1; to=$repo
[ -z "$perm_write" ] && die "no write permissions on $to"
# change head
cd $GL_REPO_BASE_ABS/$to.git
git symbolic-ref HEAD $2
echo HEAD on $to is `git symbolic-ref HEAD`
cd - > /dev/null

33
contrib/adc/symbolic-ref Executable file
View file

@ -0,0 +1,33 @@
#!/bin/sh
# allow 'git symbolic-ref' over a gitolite connection
# replaces and obsoletes the 'set-head' ADC, which was too specific
# Security: remember all arguments to ADCs must match a very conservative
# pattern; see doc/admin-defined-commands.mkd. Once that is assured, the
# symbolic-ref command has no security related side-effects, so we don't check
# arguments at all -- we just pass them on.
# Note: because of the restriction on allowed characters in arguments, you
# can't supply an arbitrary string to the '-m' option. The simplest
# work-around is-to-just-use-join-up-words-like-this if you feel the need to
# supply a "reason" string. In any case this is useless by default; you'd
# have to have core.logAllRefUpdates set for it to have any meaning.
. $(dirname $0)/adc.common-functions
[ -z "$GL_RC" ] && die "ENV GL_RC not set"
# notice we don't check for existence of arg 3, to allow the query semantics
# of git-symbolic-ref to also work
[ -z "$2" ] && die "usage: symbolic-ref /path/to/repo.git <arguments to git-symbolic-ref>"
get_rights_and_owner $1; to=$repo
[ -z "$perm_write" ] && die "no write permissions on $to"
shift
# change head
cd $GL_REPO_BASE_ABS/$to.git
git symbolic-ref "$@"