]>
Commit | Line | Data |
---|---|---|
303e5f4c | 1 | #!/bin/sh |
b33e9666 LT |
2 | . git-sh-setup-script || die "Not a git archive" |
3 | ||
303e5f4c | 4 | old=$(git-rev-parse HEAD) |
e8b11749 | 5 | new= |
a79944d7 | 6 | force= |
e8b11749 LT |
7 | branch= |
8 | while [ "$#" != "0" ]; do | |
9 | arg="$1" | |
10 | shift | |
11 | case "$arg" in | |
303e5f4c | 12 | "-f") |
e8b11749 | 13 | force=1 |
303e5f4c LT |
14 | ;; |
15 | *) | |
e2efb676 | 16 | rev=$(git-rev-parse --verify --revs-only "$arg") |
e8b11749 LT |
17 | if [ -z "$rev" ]; then |
18 | echo "unknown flag $arg" | |
19 | exit 1 | |
20 | fi | |
21 | if [ "$new" ]; then | |
22 | echo "Multiple revisions?" | |
23 | exit 1 | |
24 | fi | |
25 | new="$rev" | |
9661c256 | 26 | if [ -f "$GIT_DIR/refs/heads/$arg" ]; then |
e8b11749 LT |
27 | branch="$arg" |
28 | fi | |
29 | ;; | |
303e5f4c LT |
30 | esac |
31 | i=$(($i+1)) | |
32 | done | |
dc148411 | 33 | [ -z "$new" ] && new=$old |
303e5f4c | 34 | |
a79944d7 | 35 | if [ "$force" ] |
303e5f4c LT |
36 | then |
37 | git-read-tree --reset $new && | |
a79944d7 | 38 | git-checkout-cache -q -f -u -a |
303e5f4c | 39 | else |
a79944d7 | 40 | git-read-tree -m -u $old $new |
ef0bfa25 LT |
41 | fi |
42 | ||
43 | # | |
44 | # Switch the HEAD pointer to the new branch if it we | |
45 | # checked out a branch head, and remove any potential | |
46 | # old MERGE_HEAD's (subsequent commits will clearly not | |
47 | # be based on them, since we re-set the index) | |
48 | # | |
49 | if [ "$?" -eq 0 ]; then | |
50 | [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD" | |
51 | rm -f "$GIT_DIR/MERGE_HEAD" | |
52 | fi |