X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=usr%2Flocal%2Fbin%2Fgit-prepend-base;fp=usr%2Flocal%2Fbin%2Fgit-prepend-base;h=cd8f7c1d4a11cc2ede3ddd724b7cbfab261a08b9;hb=35359cf1b51f5d677b6351d7529f1f4986c0f7b8;hp=6b524cbf274e9709f9a8b4f105c3103fcd387a12;hpb=0fe1f1646a805dc2db2f80bf326516607884a9b1;p=matthijs%2Fservers%2Fdrsnuggles.git diff --git a/usr/local/bin/git-prepend-base b/usr/local/bin/git-prepend-base index 6b524cb..cd8f7c1 100755 --- a/usr/local/bin/git-prepend-base +++ b/usr/local/bin/git-prepend-base @@ -16,9 +16,24 @@ ARGS=() i=0 until [ "$#" -eq 0 ] do - if ! echo $1 | egrep "^(--|$BASE_PATH)" &>/dev/null; then - ARGS[$i]="$BASE_PATH/$1" + 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++))