X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-reset.sh;h=6cb073cb16f8b8d8b923bd0cd77be00da0e169e3;hb=de5f2bf3612a43af074a98fd1fcdef6a403daf3f;hp=f9995cadf563a7b3b2c1dcdeea3bf862feac2e4b;hpb=0542f48c894f924d94a2bd05f7e4cbab25656112;p=git.git diff --git a/git-reset.sh b/git-reset.sh index f9995cad..6cb073cb 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -1,7 +1,9 @@ #!/bin/sh -. git-sh-setup || die "Not a git archive" -tmp=/var/tmp/reset.$$ +USAGE='[--mixed | --soft | --hard] []' +. 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 @@ -84,6 +88,9 @@ case "$reset_type" in # it is ok if this fails -- it may already # have been culled by checkout-index. unlink $_; + while (s|/[^/]*$||) { + rmdir($_) or last; + } } } ' $tmp-exists @@ -96,4 +103,4 @@ case "$reset_type" in ;; esac -rm -f "$GIT_DIR/MERGE_HEAD" +rm -f "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/rr-cache/MERGE_RR"