Merge commit 'origin/template' into login
[matthijs/servers/drsnuggles.git] / usr / local / bin / git-prepend-base
1 #!/bin/sh
2
3 # This script prepends BASE_PATH to any arguments that are not options (start
4 # with --) and do not start with BASE_PATH already.
5 # It then executes its equivalent in /usr/bin with those updated arguments.
6 #
7 # This script is meant to provide a base path for accessing git repositories
8 # through ssh. This is similar to running git-daemon(1) with --base-path and
9 # --base-path-relaxed. 
10
11 BASE_PATH='/data/vcs/git'
12
13 # We keep an array of arguments, so we can handle quoting an spaces in
14 # arguments properly.
15 ARGS=()
16 i=0
17 until [ "$#" -eq 0 ]
18 do
19         if ! echo $1 | egrep "^(--|$BASE_PATH)" &>/dev/null; then
20                 ARGS[$i]="$BASE_PATH/$1"
21         else
22                 ARGS[$i]="$1"
23         fi
24         ((i++))
25         shift
26 done
27
28 exec /usr/bin/`basename $0` "${ARGS[@]}"