daemon: Set SO_REUSEADDR on listening sockets.
[gitweb.git] / git-reset.sh
index 04c1ac0fd2e9e147f89b92cdd831572d53bcfb88..6c9e58ad9a727ab5091b0de02e089b82cb8331dd 100755 (executable)
@@ -1,7 +1,9 @@
 #!/bin/sh
-. git-sh-setup || die "Not a git archive"
 
-tmp=/var/tmp/reset.$$
+USAGE='[--mixed | --soft | --hard]  [<commit-ish>]'
+. git-sh-setup
+
+tmp=${GIT_DIR}/reset.$$
 trap 'rm -f $tmp-*' 0 1 2 3 15
 
 reset_type=--mixed
@@ -10,6 +12,8 @@ case "$1" in
        reset_type="$1"
        shift
        ;;
+-*)
+        usage ;;
 esac
 
 rev=$(git-rev-parse --verify --default HEAD "$@") || exit
@@ -60,7 +64,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 +85,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 -v -f --
+       ' $tmp-exists
        ;;
 --soft )
        ;; # Nothing else to do