File: git-checkout.sh

package info (click to toggle)
xen 4.4.1-9
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 35,032 kB
  • sloc: ansic: 407,163; python: 53,506; sh: 9,487; asm: 6,944; makefile: 5,716; ml: 4,138; perl: 2,990; lex: 311; pascal: 252; yacc: 43; xml: 35
file content (27 lines) | stat: -rwxr-xr-x 461 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

if test $# -lt 3; then
	echo "Usage: $0 <tree> <tag> <dir>"
	exit 1
fi

TREE=$1
TAG=$2
DIR=$3

set -e

if test \! -d $DIR-remote; then
	rm -rf $DIR-remote $DIR-remote.tmp
	mkdir $DIR-remote.tmp; rmdir $DIR-remote.tmp
	$GIT clone $TREE $DIR-remote.tmp
	if test "$TAG" ; then
		cd $DIR-remote.tmp
		$GIT branch -D dummy >/dev/null 2>&1 ||:
		$GIT checkout -b dummy $TAG
		cd ..
	fi
	mv $DIR-remote.tmp $DIR-remote
fi
rm -f $DIR
ln -sf $DIR-remote $DIR