2017-03-30 09:44:27 +03:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2017-04-13 11:08:04 +03:00
|
|
|
if cd -P . 2>/dev/null; then
|
|
|
|
CHDIR='cd -P'
|
|
|
|
else
|
|
|
|
CHDIR='cd'
|
|
|
|
fi
|
|
|
|
|
2017-03-30 09:44:27 +03:00
|
|
|
quiet=
|
|
|
|
branch=
|
|
|
|
|
|
|
|
until [ $# = 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
2017-04-13 11:08:04 +03:00
|
|
|
-C|--directory) shift; $CHDIR "$1";;
|
|
|
|
-C*) $CHDIR `expr "$1" : '-C\(.*\)'`;;
|
|
|
|
--directory=*) $CHDIR `expr "$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";;
|
2017-04-12 08:22:36 +03:00
|
|
|
-b*) branch=`expr "$1" : '-b\(.*\)'`;;
|
|
|
|
--branch=*) branch=`expr "$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
|
2017-04-13 10:52:05 +03:00
|
|
|
echo updating `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
|
2017-03-30 09:44:27 +03:00
|
|
|
[ $quiet ] || set -x
|
2017-04-13 11:08:04 +03:00
|
|
|
$CHDIR "$dir"
|
2017-03-30 09:44:27 +03:00
|
|
|
git fetch "$@"
|
|
|
|
exec git checkout ${branch:+"$branch"} "$@"
|
|
|
|
else
|
2017-04-13 10:52:05 +03:00
|
|
|
echo retrieving `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
|
2017-03-30 09:44:27 +03:00
|
|
|
[ $quiet ] || set -x
|
|
|
|
exec git clone "$url" "$dir" "$@"
|
|
|
|
fi
|