2 . git-sh-setup-script || die "Not a git archive"
5 trap 'rm -f $tmp-*' 0 1 2 3 15
9 --mixed | --soft | --hard)
15 rev=$(git-rev-parse --verify --default HEAD "$@") || exit
16 rev=$(git-rev-parse --verify $rev^0) || exit
18 # We need to remember the set of paths that _could_ be left
19 # behind before a hard reset, so that we can remove them.
20 if test "$reset_type" = "--hard"
23 git-ls-files --stage -z
24 git-rev-parse --verify HEAD 2>/dev/null &&
25 git-ls-tree -r -z HEAD
32 my ($info, $path) = split(/\t/, $_);
33 next if ($info =~ / tree /);
42 # Soft reset does not touch the index file nor the working tree
43 # at all, but requires them in a good order. Other resets reset
44 # the index file to the tree object we are switching to.
45 if test "$reset_type" = "--soft"
47 if test -f "$GIT_DIR/MERGE_HEAD" ||
48 test "" != "$(git-ls-files --unmerged)"
50 die "Cannot do a soft reset in the middle of a merge."
53 git-read-tree --reset "$rev" || exit
56 # Any resets update HEAD to the head being switched to.
57 if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
59 echo "$orig" >"$GIT_DIR/ORIG_HEAD"
61 rm -f "$GIT_DIR/ORIG_HEAD"
63 echo "$rev" >"$GIT_DIR/HEAD"
67 # Hard reset matches the working tree to that of the tree
69 git-checkout-cache -f -u -q -a
70 git-ls-files --cached -z |
79 open $fh, "<", $ARGV[0]
80 or die "cannot open $ARGV[0]";
83 if (! exists $keep{$_}) {
87 ' $tmp-exists | xargs -0 rm -v -f --
90 ;; # Nothing else to do
92 # Report what has not been updated.
93 git-update-cache --refresh
97 rm -f "$GIT_DIR/MERGE_HEAD"