git: Make the git-wrapper script a bit more readable.
[matthijs/servers/drsnuggles.git] / usr / local / bin / git-wrapper
index cd8f7c1d4a11cc2ede3ddd724b7cbfab261a08b9..1920599af45e46adb61b37b7f83e9126804be48c 100755 (executable)
 
 BASE_PATH='/data/vcs/git'
 
+function init_repos() {
+       mkdir "$1" &> /dev/null  || return 1 
+       (cd $1 && git --bare init &> /dev/null) || return 1
+}
+
 # We keep an array of arguments, so we can handle quoting an spaces in
 # arguments properly.
 ARGS=()
@@ -27,9 +32,10 @@ do
                        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)
+               # When the client wants us to receive a pack, create the git
+               # repository if it does not exist yet   
+               if [ "`basename $0`" = "git-receive-pack" -a ! -e "$DIR" ]; then
+                       init_repos "$DIR"
                fi
                ARGS[$i]="$DIR"
        else