3 USAGE='[--mixed | --soft | --hard] [<commit-ish>]'
7 trap 'rm -f $tmp-*' 0 1 2 3 15
11 --mixed | --soft | --hard)
19 rev=$(git-rev-parse --verify --default HEAD "$@") || exit
20 rev=$(git-rev-parse --verify $rev^0) || exit
22 # We need to remember the set of paths that _could_ be left
23 # behind before a hard reset, so that we can remove them.
24 if test "$reset_type" = "--hard"
27 git-ls-files --stage -z
28 git-rev-parse --verify HEAD 2>/dev/null &&
29 git-ls-tree -r -z HEAD
36 my ($info, $path) = split(/\t/, $_);
37 next if ($info =~ / tree /);
46 # Soft reset does not touch the index file nor the working tree
47 # at all, but requires them in a good order. Other resets reset
48 # the index file to the tree object we are switching to.
49 if test "$reset_type" = "--soft"
51 if test -f "$GIT_DIR/MERGE_HEAD" ||
52 test "" != "$(git-ls-files --unmerged)"
54 die "Cannot do a soft reset in the middle of a merge."
57 git-read-tree --reset "$rev" || exit
60 # Any resets update HEAD to the head being switched to.
61 if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
63 echo "$orig" >"$GIT_DIR/ORIG_HEAD"
65 rm -f "$GIT_DIR/ORIG_HEAD"
67 git-update-ref HEAD "$rev"
71 # Hard reset matches the working tree to that of the tree
73 git-checkout-index -f -u -q -a
74 git-ls-files --cached -z |
83 open $fh, "<", $ARGV[0]
84 or die "cannot open $ARGV[0]";
87 if (! exists $keep{$_}) {
88 # it is ok if this fails -- it may already
89 # have been culled by checkout-index.
96 ;; # Nothing else to do
98 # Report what has not been updated.
99 git-update-index --refresh
103 rm -f "$GIT_DIR/MERGE_HEAD"