# vim: ft=sh # Simple echo wrapper for stage marking echo_stage() { echo "========== $@ ==========" } # Fetch git repository to WORKSPACE and create workspace in current directory # First agument has to be a source URL # Second argument is name of directory to which will be directory cloned in. # Second argument is optional and should be branch name (master is used if not # provided). git_fetch() { local BRANCH="$3" [ -n "$BRANCH" ] || BRANCH=master if [ -d "$WORKSPACE/$2" ]; then git --git-dir="$WORKSPACE/$2" --bare fetch --prune --prune-tags --force "$1" "$BRANCH:$BRANCH" else git clone --bare "$1" "$WORKSPACE/$2" fi git --git-dir="$WORKSPACE/$2" --bare worktree add --detach $2 $BRANCH }