#!/bin/sh GITREMOTE=git.acdw.net GITROOT=/git POSTUPDATEHOOK=/tmp/post-update.hook init_post_update_hook() { # This post-update hook will update cgit's date display. cat <<\EOF #!/bin/sh # Update "agefile" for cgit # The default location is /info/web/last-modified agefile="$(git rev-parse --git-dir)/info/web/last-modified" mkdir -p "$(dirname "$agefile")" git for-each-ref > "$agefile" \ --sort=-authordate --count=1 \ --format='%(authordate:iso8601)' # Prepare a packed repository for use over dumb transports git update-server-info EOF } ## Setup git ls-files > /dev/null || exit 1 test -f "$POSTUPDATEHOOK" || init_post_update_hook > "$POSTUPDATEHOOK" # consider --git-dir as well .. however --git-dir would require more massaging # of the output. local="$(git rev-parse --show-toplevel)" name="${local##*/}" remote="$GITROOT/$name.git" ## Remote work # Initiate the repository echo "ssh \"$GITREMOTE\" git init --bare \"$remote\"" ssh "$GITREMOTE" git init --bare "$remote" # Add a description echo "ssh \"$GITREMOTE\" ed \"$remote/description\"" ssh "$GITREMOTE" ed "$remote/description" # Add post-update-hook echo "scp \"$POSTUPDATEHOOK\" \"$GITREMOTE:$remote/hooks/post-update\"" scp "$POSTUPDATEHOOK" "$GITREMOTE:$remote/hooks/post-update" echo "ssh \"$GITREMOTE\" chmod +x \"$remote/hooks/post-update\"" ssh "$GITREMOTE" chmod +x "$remote/hooks/post-update" ## Local work echo "git remote add origin \"$GITREMOTE:$remote\"" git remote add origin "$GITREMOTE:$remote" echo -n "Push to remote? " read case "$REPLY" in y*|Y*|'') branch="$(git branch --show-current)" echo git push -u origin "$branch" git push -u origin "$branch" ;; *) ;; esac