diff --git a/git-reset.sh b/git-reset.sh
index dfa9cb8bb17f6f8694d0c639fe8b1663f9ec3c8f..6cb073cb16f8b8d8b923bd0cd77be00da0e169e3 100755 (executable)
--- a/git-reset.sh
+++ b/git-reset.sh
#!/bin/sh
#!/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
trap 'rm -f $tmp-*' 0 1 2 3 15
reset_type=--mixed
reset_type="$1"
shift
;;
reset_type="$1"
shift
;;
+-*)
+ usage ;;
esac
rev=$(git-rev-parse --verify --default HEAD "$@") || exit
esac
rev=$(git-rev-parse --verify --default HEAD "$@") || exit
else
rm -f "$GIT_DIR/ORIG_HEAD"
fi
else
rm -f "$GIT_DIR/ORIG_HEAD"
fi
-echo "$rev" >"$GIT_DIR/HEAD"
+git-update-ref HEAD "$rev"
case "$reset_type" in
--hard )
case "$reset_type" in
--hard )
# it is ok if this fails -- it may already
# have been culled by checkout-index.
unlink $_;
# it is ok if this fails -- it may already
# have been culled by checkout-index.
unlink $_;
+ while (s|/[^/]*$||) {
+ rmdir($_) or last;
+ }
}
}
' $tmp-exists
}
}
' $tmp-exists
;;
esac
;;
esac
-rm -f "$GIT_DIR/MERGE_HEAD"
+rm -f "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/rr-cache/MERGE_RR"