[PATCH] Emit base objects of a delta chain when the delta is output.
[tgit.git] / git-checkout-script
blobea7fef54ab6e1a6e04b87aa749c19ae916190d26
1 #!/bin/sh
2 : ${GIT_DIR=.git}
3 old=$(git-rev-parse HEAD)
4 new=
5 force=
6 branch=
7 while [ "$#" != "0" ]; do
8 arg="$1"
9 shift
10 case "$arg" in
11 "-f")
12 force=1
15 rev=$(git-rev-parse --verify --revs-only "$arg")
16 if [ -z "$rev" ]; then
17 echo "unknown flag $arg"
18 exit 1
20 if [ "$new" ]; then
21 echo "Multiple revisions?"
22 exit 1
24 new="$rev"
25 if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
26 branch="$arg"
29 esac
30 i=$(($i+1))
31 done
32 [ -z "$new" ] && new=$old
34 if [ "$force" ]
35 then
36 git-read-tree --reset $new &&
37 git-checkout-cache -q -f -u -a
38 else
39 git-read-tree -m -u $old $new
43 # Switch the HEAD pointer to the new branch if it we
44 # checked out a branch head, and remove any potential
45 # old MERGE_HEAD's (subsequent commits will clearly not
46 # be based on them, since we re-set the index)
48 if [ "$?" -eq 0 ]; then
49 [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD"
50 rm -f "$GIT_DIR/MERGE_HEAD"