git: Make git-wrapper exit if repos creation fails.
[matthijs/servers/drsnuggles.git] / usr / local / bin / git-wrapper
index 1920599af45e46adb61b37b7f83e9126804be48c..570a47d2d737a82fcfda6365bd311a205b9ad2b5 100755 (executable)
@@ -9,10 +9,12 @@
 # --base-path-relaxed. 
 
 BASE_PATH='/data/vcs/git'
+POST_UPDATE_HOOK="$BASE_PATH/hooks/post-update"
 
 function init_repos() {
        mkdir "$1" &> /dev/null  || return 1 
        (cd $1 && git --bare init &> /dev/null) || return 1
+       cp -P "$POST_UPDATE_HOOK" "$1/hooks/" || return 1
 }
 
 # We keep an array of arguments, so we can handle quoting an spaces in
@@ -35,7 +37,7 @@ do
                # 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"
+                       init_repos "$DIR" || exit 1
                fi
                ARGS[$i]="$DIR"
        else