#!/bin/sh -e if [ "$1" = "--private" -o "$1" = "-p" ]; then PRIVATE=true shift else PRIVATE=false fi . "`dirname $0`"/common TREE="`echo $1 |sed -e 's,\.git$,,'`" [ -z "$TREE" ] && exit 1 B=`basename $TREE` D=`dirname $TREE` if $PRIVATE; then SERVER=ssh://$PRIVUSER@dev-private-review.linaro.org:29418/$TREE.git shift else SERVER=ssh://$USER@android-review.linaro.org:29418/$TREE.git fi OK=false if [ -d $SRC/$TREE ]; then cd $SRC/$TREE git pull git fetch --all if [ -n "$2" ]; then if git checkout $2 &>/dev/null; then OK=true elif echo $2 |grep -q refs/tags/; then if git checkout `basename $2`; then OK=true fi elif git checkout -b $2 origin/$2; then OK=true fi if ! $OK; then if git checkout `basename $2`; then OK=true fi fi fi exit 0 fi mkdir -p $SRC/$D cd $SRC/$D git clone $SERVER cd $B [ -n "$EMAIL" ] && git config user.email $EMAIL gitdir=$(git rev-parse --git-dir); scp -p -P 29418 $USER@android-review.linaro.org:hooks/commit-msg ${gitdir}/hooks/ git remote add aosp https://android-review.googlesource.com/$TREE.git # No way to do this without hardcodes... case $TREE in platform/external/ffmpeg) git remote add upstream git://source.ffmpeg.org/ffmpeg.git ;; platform/external/x264) git remote add upstream git://git.videolan.org/x264.git ;; platform/external/busybox) git remote add upstream git://busybox.net/busybox.git ;; toolchain/binutils-current) git remote add upstream git://sourceware.org/git/binutils.git git remote add hjl git://git.kernel.org/pub/scm/linux/kernel/git/hjl/binutils.git ;; esac git fetch aosp || git remote rm aosp git fetch --all if [ -n "$2" ]; then if echo $2 |grep -q refs/tags/; then if git checkout `basename $2`; then OK=true fi elif git checkout -b $2 origin/$2; then OK=true elif git checkout -b $2 origin/$2 2>&1 |grep -q "already exists"; then OK=true fi fi if ! $OK; then for i in $VERSIONS; do if git checkout -b $i origin/$i; then OK=true break elif git checkout -b $i origin/$i 2>&1 |grep -q "already exists"; then OK=true break fi done fi if ! $OK; then git checkout android-${ANDROIDVERSION}_r${ANDROIDREVISION} fi