| old=$(git-rev-parse HEAD) |
| while [ "$#" != "0" ]; do |
| rev=$(git-rev-parse --verify --revs-only "$arg") |
| echo "Multiple revisions?" |
| if [ -f "$GIT_DIR/refs/heads/$arg" ]; then |
| [ -z "$new" ] && new=$old |
| git-read-tree --reset $new && |
| git-checkout-cache -q -f -u -a |
| git-read-tree -m -u $old $new |
| # Switch the HEAD pointer to the new branch if it we |
| # checked out a branch head, and remove any potential |
| # old MERGE_HEAD's (subsequent commits will clearly not |
| # be based on them, since we re-set the index) |
| [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD" |
| rm -f "$GIT_DIR/MERGE_HEAD" |