2017-03-30 02:44:27 -04:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2017-04-13 20:45:48 -04:00
|
|
|
if (cd -P .) 2>/dev/null; then
|
2017-04-13 04:08:04 -04:00
|
|
|
CHDIR='cd -P'
|
|
|
|
else
|
|
|
|
CHDIR='cd'
|
|
|
|
fi
|
|
|
|
|
2017-03-30 02:44:27 -04:00
|
|
|
quiet=
|
|
|
|
branch=
|
|
|
|
|
|
|
|
until [ $# = 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
2017-04-13 04:08:04 -04:00
|
|
|
-C|--directory) shift; $CHDIR "$1";;
|
|
|
|
-C*) $CHDIR `expr "$1" : '-C\(.*\)'`;;
|
|
|
|
--directory=*) $CHDIR `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
|
2017-04-29 23:52:06 -04:00
|
|
|
[ x"$branch" = x ] && unset branch || :
|
2017-03-30 02:44:27 -04:00
|
|
|
if [ -d "$dir" ]; then
|
2017-04-13 03:52:05 -04:00
|
|
|
echo updating `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
|
2017-03-30 02:44:27 -04:00
|
|
|
[ $quiet ] || set -x
|
2017-04-13 04:08:04 -04:00
|
|
|
$CHDIR "$dir"
|
2017-04-30 06:53:42 -04:00
|
|
|
${branch+git} ${branch+fetch} ${branch+"$@"}
|
2017-04-29 23:52:06 -04:00
|
|
|
exec git ${branch+checkout} "${branch-pull}" "$@"
|
2017-03-30 02:44:27 -04:00
|
|
|
else
|
2017-04-13 03:52:05 -04:00
|
|
|
echo retrieving `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
|
2017-03-30 02:44:27 -04:00
|
|
|
[ $quiet ] || set -x
|
2017-04-30 06:53:42 -04:00
|
|
|
exec git clone ${branch+--branch} ${branch+"$branch"} "$url" "$dir" "$@"
|
2017-03-30 02:44:27 -04:00
|
|
|
fi
|