2017-03-30 02:44:27 -04:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
quiet=
|
|
|
|
branch=
|
|
|
|
|
|
|
|
until [ $# = 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
2017-03-30 03:04:14 -04:00
|
|
|
-C|--directory) shift; cd "$1";;
|
2017-04-12 01:22:36 -04:00
|
|
|
-C*) cd `expr "$1" : '-C\(.*\)'`;;
|
|
|
|
--directory=*) cd `expr "$1" : '[^=]*=\(.*\)'`;;
|
2017-03-30 02:44:27 -04:00
|
|
|
-q) quiet=1;;
|
2017-03-30 03:04:14 -04:00
|
|
|
-b|--branch) shift; branch="$1";;
|
2017-04-12 01:22:36 -04:00
|
|
|
-b*) branch=`expr "$1" : '-b\(.*\)'`;;
|
|
|
|
--branch=*) branch=`expr "$1" : '[^=]*=\(.*\)'`;;
|
2017-03-30 02:44:27 -04:00
|
|
|
-*) echo "unknown option: $1" 1>&2; exit 1;;
|
|
|
|
*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
url="$1"
|
|
|
|
dir="$2"
|
|
|
|
shift 2
|
|
|
|
if [ -d "$dir" ]; then
|
2017-04-12 01:22:36 -04:00
|
|
|
echo updating `expr "$dir" : '*/\(.*\)'` ...
|
2017-03-30 02:44:27 -04:00
|
|
|
[ $quiet ] || set -x
|
|
|
|
cd "$dir"
|
|
|
|
git fetch "$@"
|
|
|
|
exec git checkout ${branch:+"$branch"} "$@"
|
|
|
|
else
|
2017-04-12 01:22:36 -04:00
|
|
|
echo retrieving `expr "$dir" : '*/\(.*\)'` ...
|
2017-03-30 02:44:27 -04:00
|
|
|
[ $quiet ] || set -x
|
|
|
|
exec git clone "$url" "$dir" "$@"
|
|
|
|
fi
|