git: Make git-wrapper create symlinks instead of copying them.
[matthijs/servers/drsnuggles.git] / usr / local / bin / git-wrapper
index 6896ec8904e6dfe0677522564effdbb36a1868c7..5481ffbf42f89e29303a64954e3429b0e1efab0f 100755 (executable)
@@ -9,12 +9,15 @@
 # --base-path-relaxed. 
 
 BASE_PATH='/data/vcs/git'
-POST_UPDATE_HOOK="$BASE_PATH/hooks/post-update"
+HOOKS_PATH="$BASE_PATH/hooks"
+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
+       for hook in $HOOKS; do
+           ln -s "$HOOKS_PATH/$hook" "$1/hooks/" || return 1
+       done
 }
 
 # We keep an array of arguments, so we can handle quoting an spaces in
@@ -37,7 +40,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