#!/bin/bash

# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated.  It is passed arguments in through
# stdin in the form
#  <oldrev> <newrev> <refname>
# For example:
#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample

#GIT_WORK_TREE=~/tip/book/ git checkout

env -i git update-server-info

current="$(pwd)"
home=$(echo ~)
local="${current#${home}/}"
lib="repo"
root="${local#${lib}/}"
type="git"
dir="${root%/${type}}"

#exit -1

pushd ~/...
pwd
env -i git pull origin master
env -i git remote | grep -q '^github$' && env -i git push github master
env -i git submodule init
env -i git submodule update
env -i bin/git/post-receive-email
popd
