aboutsummaryrefslogtreecommitdiff
path: root/git-checkout-script
blob: e8e777f1f23e71fde909ce0d831d4a319993c0ab (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
#!/bin/sh
: ${GIT_DIR=.git}
old=$(git-rev-parse HEAD)
new=$(git-rev-parse --revs-only "$@")
new=${new:-$old}
args=($(git-rev-parse --no-revs "$@"))

i=0
force=0
while [ $i -lt ${#args} ]; do
    case "${args[$i]}" in
	"-f")
		force=1;;
	"")
		;;
	*)
		echo "unknown flag ${args[$i]}"
		exit 1;;
    esac
    i=$(($i+1))
done

if $force
then
    git-read-tree --reset $new &&
	git-checkout-cache -q -f -u -a &&
	echo $new > "$GIT_DIR/HEAD"
else
    git-read-tree -m -u $old $new && echo $new > "$GIT_DIR/HEAD"
fi