1#!/bin/sh
2
3if test $# -lt 3; then
4	echo "Usage: $0 <tree> <tag> <dir>"
5	exit 1
6fi
7
8TREE=$1
9TAG=$2
10DIR=$3
11
12set -e
13
14if test \! -d $DIR-remote; then
15	rm -rf $DIR-remote $DIR-remote.tmp
16	mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
17	$GIT clone $TREE $DIR-remote.tmp
18	if test "$TAG" ; then
19		cd $DIR-remote.tmp
20		$GIT branch -D dummy >/dev/null 2>&1 ||:
21		$GIT checkout -b dummy $TAG
22		cd ..
23	fi
24	mv $DIR-remote.tmp $DIR-remote
25fi
26rm -f $DIR
27ln -sf $DIR-remote $DIR
28