#!/bin/sh branches= ref= while [ -n "$1" -a -z "${1%%-*}" ]; do opt="$1"; shift; case "$opt" in -b) branches=1;; -r) ref="$1"; shift;; esac done [ "$#" -eq 3 ] || { echo "Usage: $0 [-b] [-r ] " } r() { local cmd="$1"; shift $cmd "$@" || exit "$?" } r git clone ${ref:+--reference "$ref"} "$1" "$3" $GSC_GIT_OPTIONS r cd "$3" REPO="$(git log | grep git-svn-id | head -n1 | awk '{print $2}' | cut -d@ -f1)" dir="${2##*/}" url="${2%%/}" [ trunk = "$dir" ] && { opts="-T trunk" url="${url%%/trunk}" REPO="${REPO%%/trunk}" } [ -n "$branches" ] && opts="-T trunk -t tags -b branches" [ "$REPO" = "$url" ] && REPO= r git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*' r git fetch origin r git svn init "$url" $opts ${REPO:+--rewrite-root "$REPO"} r git svn rebase