--- /dev/null
+#!/bin/sh
+
+# This script prepends BASE_PATH to any arguments that are not options (start
+# with --) and do not start with BASE_PATH already.
+# It then executes its equivalent in /usr/bin with those updated arguments.
+#
+# This script is meant to provide a base path for accessing git repositories
+# through ssh. This is similar to running git-daemon(1) with --base-path and
+# --base-path-relaxed.
+
+BASE_PATH='/data/vcs/git'
+
+# We keep an array of arguments, so we can handle quoting an spaces in
+# arguments properly.
+ARGS=()
+i=0
+until [ "$#" -eq 0 ]
+do
+ if ! echo $1 | egrep "^(--|$BASE_PATH)" &>/dev/null; then
+ ARGS[$i]="$BASE_PATH/$1"
+ else
+ ARGS[$i]="$1"
+ fi
+ ((i++))
+ shift
+done
+
+exec /usr/bin/`basename $0` "${ARGS[@]}"