#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+
+USAGE='[--mixed | --soft | --hard] [<commit-ish>]'
+. git-sh-setup
tmp=/var/tmp/reset.$$
trap 'rm -f $tmp-*' 0 1 2 3 15
reset_type="$1"
shift
;;
+-*)
+ usage ;;
esac
rev=$(git-rev-parse --verify --default HEAD "$@") || exit
else
rm -f "$GIT_DIR/ORIG_HEAD"
fi
-echo "$rev" >"$GIT_DIR/HEAD"
+git-update-ref HEAD "$rev"
case "$reset_type" in
--hard )
while (<$fh>) {
chomp;
if (! exists $keep{$_}) {
- print "$_\0";
+ # it is ok if this fails -- it may already
+ # have been culled by checkout-index.
+ unlink $_;
}
}
- ' $tmp-exists | xargs -0 rm -f --
+ ' $tmp-exists
;;
--soft )
;; # Nothing else to do