diff options
Diffstat (limited to 'git-reset.sh')
| -rwxr-xr-x | git-reset.sh | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/git-reset.sh b/git-reset.sh index e028ff65db..2086d26d34 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -1,6 +1,10 @@ #!/bin/sh . git-sh-setup || die "Not a git archive" +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 |
