#!/bin/sh # Clone a wanted module if absent. usage () { echo "Usage:" `basename $0` \ "[-h|-u] [-B] [-R dir] [-b branch] [-n name] -m part [--] [options...]"; } # e.g. to set up a new branch's work-space: # git clone -b X.Y ../bare/qt/qt5.git Qt-X.Y && cd Qt-X.Y # qteach -b -o -Q . -t default qtclonew -R /home/eddy/bare/qt/ '${BRANCH:+-b $BRANCH}' -m # ./init-repository -f --branch --mirror ssh://codereview.qt-project.org/ help () { usage cat <&2; die "Unrecognised option: $@" ;; *) break ;; esac done [ "$PART" ] || die "No module specified to clone" if echo "$PART" | grep -q '^[a-z][a-z0-9]*://' then if [ "$ROOT" ] then warn "Ignoring --root $ROOT as --module got a full URL" fi ROOT= elif [ -z "$ROOT" ] then ROOT='ssh://codereview.qt-project.org/qt/' fi STEM=`basename "$PART"` if [ "$ROOT" ] then PART="$ROOT$STEM" fi if [ -z "$BARE" ] then [ -n "$NAME" ] || NAME="${STEM%.git}" [ -e "$NAME/.git" ] else [ -n "$NAME" ] || NAME="${STEM%.git}.git" [ -d "$NAME" ] # Do *not* enquote OPTS or BARE: fi || if git clone $BARE $OPTS "$@" "$PART" "$NAME" then if [ -z "$BARE" ] then qtrepoinit "$NAME" elif echo "$PART" | grep -q '^[a-z][a-z0-9]*://' then (if cd "$NAME" then # For some perverse reason, bare repos don't get any git branch -r git remote rm origin git remote add origin "$PART" fi) fi fi