From ac18da62cddd42ae3e1f7c800f0c70547ae663aa Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 30 Mar 2009 09:15:36 +0200 Subject: [PATCH] git: Add scripts to enable a base path for git over ssh. These files provide wrappers aroudn git-{receive,upload}-pack that prepend the base path '/data/vcs/git/' to each non-option argument. This enables git urls over ssh to leave out this base path. --- usr/local/bin/git-prepend-base | 28 ++++++++++++++++++++++++++++ usr/local/bin/git-receive-pack | 1 + usr/local/bin/git-upload-pack | 1 + 3 files changed, 30 insertions(+) create mode 100755 usr/local/bin/git-prepend-base create mode 120000 usr/local/bin/git-receive-pack create mode 120000 usr/local/bin/git-upload-pack diff --git a/usr/local/bin/git-prepend-base b/usr/local/bin/git-prepend-base new file mode 100755 index 0000000..6b524cb --- /dev/null +++ b/usr/local/bin/git-prepend-base @@ -0,0 +1,28 @@ +#!/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[@]}" diff --git a/usr/local/bin/git-receive-pack b/usr/local/bin/git-receive-pack new file mode 120000 index 0000000..f0c4399 --- /dev/null +++ b/usr/local/bin/git-receive-pack @@ -0,0 +1 @@ +git-prepend-base \ No newline at end of file diff --git a/usr/local/bin/git-upload-pack b/usr/local/bin/git-upload-pack new file mode 120000 index 0000000..f0c4399 --- /dev/null +++ b/usr/local/bin/git-upload-pack @@ -0,0 +1 @@ +git-prepend-base \ No newline at end of file -- 2.30.2