1#!/bin/sh
2: ${GIT_DIR=.git}
3old=$(git-rev-parse HEAD)
4new=$(git-rev-parse --revs-only "$@")
5new=${new:-$old}
6args=($(git-rev-parse --no-revs "$@"))
7
8i=0
9force=0
10while [ $i -lt ${#args} ]; do
11 case "${args[$i]}" in
12 "-f")
13 force=1;;
14 "")
15 ;;
16 *)
17 echo "unknown flag ${args[$i]}"
18 exit 1;;
19 esac
20 i=$(($i+1))
21done
22
23if $force
24then
25 git-read-tree --reset $new &&
26 git-checkout-cache -q -f -u -a &&
27 echo $new > "$GIT_DIR/HEAD"
28else
29 git-read-tree -m -u $old $new && echo $new > "$GIT_DIR/HEAD"
30fi