From: Matthijs Kooijman Date: Thu, 13 Aug 2009 09:22:56 +0000 (+0200) Subject: git: Rename git-prepend-base to git-wrapper. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fservers%2Fdrsnuggles.git;a=commitdiff_plain;h=72f5c5eeda71df1ed0efd64a752f004862ac59ab git: Rename git-prepend-base to git-wrapper. The script now does more than prepending the basedir, so give it a more general name. --- diff --git a/usr/local/bin/git-prepend-base b/usr/local/bin/git-prepend-base deleted file mode 100755 index cd8f7c1..0000000 --- a/usr/local/bin/git-prepend-base +++ /dev/null @@ -1,43 +0,0 @@ -#!/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 "^--" &>/dev/null; then - # This is an option argument, leave it untouched - ARGS[$i]="$1" - elif echo $1 | egrep ".git$" &>/dev/null; then - # This is a path to a git repository - DIR="$1" - # Prepend BASE_PATH if the path does not start with it already. - if ! echo $DIR | egrep "^$BASE_PATH" &>/dev/null; then - DIR="$BASE_PATH/$DIR" - fi - - # Create the git repository if it does not exist yet - if [ ! -e "$DIR" ]; then - mkdir "$DIR" &> /dev/null && (cd $DIR && git --bare init &> /dev/null) - fi - ARGS[$i]="$DIR" - else - # Not a path to a git repository, leave untouched. - 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 index f0c4399..b37e17d 120000 --- a/usr/local/bin/git-receive-pack +++ b/usr/local/bin/git-receive-pack @@ -1 +1 @@ -git-prepend-base \ No newline at end of file +git-wrapper \ No newline at end of file diff --git a/usr/local/bin/git-upload-pack b/usr/local/bin/git-upload-pack index f0c4399..b37e17d 120000 --- a/usr/local/bin/git-upload-pack +++ b/usr/local/bin/git-upload-pack @@ -1 +1 @@ -git-prepend-base \ No newline at end of file +git-wrapper \ No newline at end of file diff --git a/usr/local/bin/git-wrapper b/usr/local/bin/git-wrapper new file mode 100755 index 0000000..cd8f7c1 --- /dev/null +++ b/usr/local/bin/git-wrapper @@ -0,0 +1,43 @@ +#!/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 "^--" &>/dev/null; then + # This is an option argument, leave it untouched + ARGS[$i]="$1" + elif echo $1 | egrep ".git$" &>/dev/null; then + # This is a path to a git repository + DIR="$1" + # Prepend BASE_PATH if the path does not start with it already. + if ! echo $DIR | egrep "^$BASE_PATH" &>/dev/null; then + DIR="$BASE_PATH/$DIR" + fi + + # Create the git repository if it does not exist yet + if [ ! -e "$DIR" ]; then + mkdir "$DIR" &> /dev/null && (cd $DIR && git --bare init &> /dev/null) + fi + ARGS[$i]="$DIR" + else + # Not a path to a git repository, leave untouched. + ARGS[$i]="$1" + fi + ((i++)) + shift +done + +exec /usr/bin/`basename $0` "${ARGS[@]}"