blob: 9ed7d7c76ecdba22e3f967a5973ccf74d3296a0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh
set -e
if (cd -P .) 2>/dev/null; then
CHDIR='cd -P'
else
CHDIR='cd'
fi
quiet=
branch=
until [ $# = 0 ]; do
case "$1" in
--) shift; break;;
-C|--directory) shift; $CHDIR "$1";;
-C*) $CHDIR `expr "$1" : '-C\(.*\)'`;;
--directory=*) $CHDIR `expr "$1" : '[^=]*=\(.*\)'`;;
-q) quiet=1;;
-b|--branch) shift; branch="$1";;
-b*) branch=`expr "$1" : '-b\(.*\)'`;;
--branch=*) branch=`expr "$1" : '[^=]*=\(.*\)'`;;
-*) echo "unknown option: $1" 1>&2; exit 1;;
*) break;;
esac
shift
done
url="$1"
dir="$2"
shift 2
[ x"$branch" = x ] && unset branch || :
if [ -d "$dir" ]; then
if [ x"$(git -C "$dir" describe --tags)" = x"$branch" ]; then
exit 0 # already up-to-date
fi
echo updating `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
[ $quiet ] || set -x
$CHDIR "$dir"
${branch+git} ${branch+fetch} ${branch+"$@"}
exec git ${branch+checkout} "${branch-pull}" "$@"
else
echo retrieving `expr "/$dir/" : '.*/\([^/][^/]*\)/'` ...
[ $quiet ] || set -x
exec git clone ${branch+--branch} ${branch+"$branch"} "$url" "$dir" "$@"
fi
|