merge-recursive: match the unmerged index entry behaviour with merge-resolve
[gitweb.git] / git-reset.sh
index e028ff65dba75699580d47fbbe3fa6825774af83..72ef303aedc69a1d9cdd946a91059638cb2e550a 100755 (executable)
@@ -1,5 +1,9 @@
 #!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
+
+usage () {
+       die 'Usage: git reset [--mixed | --soft | --hard]  [<commit-ish>]'
+}
 
 tmp=/var/tmp/reset.$$
 trap 'rm -f $tmp-*' 0 1 2 3 15
@@ -10,6 +14,8 @@ case "$1" in
        reset_type="$1"
        shift
        ;;
+-*)
+        usage ;;
 esac
 
 rev=$(git-rev-parse --verify --default HEAD "$@") || exit
@@ -60,7 +66,7 @@ then
 else
        rm -f "$GIT_DIR/ORIG_HEAD"
 fi
-echo "$rev" >"$GIT_DIR/HEAD"
+git-update-ref HEAD "$rev"
 
 case "$reset_type" in
 --hard )
@@ -81,10 +87,12 @@ case "$reset_type" in
                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