3 USAGE='[--mixed | --soft | --hard] [<commit-ish>]'
7 TOP=$(git-rev-parse --show-cdup)
16 --mixed | --soft | --hard)
26 1) rev=$(git-rev-parse --verify "$1") || exit ;;
29 rev=$(git-rev-parse --verify $rev^0) || exit
31 # We need to remember the set of paths that _could_ be left
32 # behind before a hard reset, so that we can remove them.
33 if test "$reset_type" = "--hard"
38 # Soft reset does not touch the index file nor the working tree
39 # at all, but requires them in a good order. Other resets reset
40 # the index file to the tree object we are switching to.
41 if test "$reset_type" = "--soft"
43 if test -f "$GIT_DIR/MERGE_HEAD" ||
44 test "" != "$(git-ls-files --unmerged)"
46 die "Cannot do a soft reset in the middle of a merge."
49 git-read-tree --reset $update "$rev" || exit
52 # Any resets update HEAD to the head being switched to.
53 if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
55 echo "$orig" >"$GIT_DIR/ORIG_HEAD"
57 rm -f "$GIT_DIR/ORIG_HEAD"
59 git-update-ref -m "reset $reset_type $*" HEAD "$rev"
64 ;; # Nothing else to do
66 ;; # Nothing else to do
68 # Report what has not been updated.
69 git-update-index --refresh
73 rm -f "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/rr-cache/MERGE_RR" \
74 "$GIT_DIR/SQUASH_MSG" "$GIT_DIR/MERGE_MSG"
76 exit $update_ref_status