3 USAGE='[--mixed | --soft | --hard] [<commit-ish>]'
9 --mixed | --soft | --hard)
19 1) rev=$(git-rev-parse --verify "$1") || exit ;;
22 rev=$(git-rev-parse --verify $rev^0) || exit
24 # We need to remember the set of paths that _could_ be left
25 # behind before a hard reset, so that we can remove them.
26 if test "$reset_type" = "--hard"
31 # Soft reset does not touch the index file nor the working tree
32 # at all, but requires them in a good order. Other resets reset
33 # the index file to the tree object we are switching to.
34 if test "$reset_type" = "--soft"
36 if test -f "$GIT_DIR/MERGE_HEAD" ||
37 test "" != "$(git-ls-files --unmerged)"
39 die "Cannot do a soft reset in the middle of a merge."
42 git-read-tree --reset $update "$rev" || exit
45 # Any resets update HEAD to the head being switched to.
46 if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
48 echo "$orig" >"$GIT_DIR/ORIG_HEAD"
50 rm -f "$GIT_DIR/ORIG_HEAD"
52 git-update-ref -m "reset $reset_type $*" HEAD "$rev"
57 ;; # Nothing else to do
59 ;; # Nothing else to do
61 # Report what has not been updated.
62 git-update-index --refresh
66 rm -f "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/rr-cache/MERGE_RR" "$GIT_DIR/SQUASH_MSG"
68 exit $update_ref_status