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