X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=git-stash.sh;h=7ce818bd1baecfb48447f862bb2654ccbd3cf2ff;hb=89d1b5b8f70c1572c71ec04d5bb164f0849815dc;hp=750f360da9730423fde863de391ecbe550b172cf;hpb=92e39e44542b34923294fbb45069b8140d19976d;p=git.git diff --git a/git-stash.sh b/git-stash.sh index 750f360da..7ce818bd1 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -210,19 +210,9 @@ list_stash () { } show_stash () { - have_stash || die 'No stash found' - - flags=$(git rev-parse --no-revs --flags "$@") - if test -z "$flags" - then - flags=--stat - fi - - w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") && - b_commit=$(git rev-parse --quiet --verify "$w_commit^") || - die "'$*' is not a stash" + assert_stash_like "$@" - git diff $flags $b_commit $w_commit + git diff ${FLAGS:---stat} $b_commit $w_commit } # @@ -423,6 +413,13 @@ apply_stash () { fi } +pop_stash() { + assert_stash_ref "$@" + + apply_stash "$@" && + drop_stash "$@" +} + drop_stash () { assert_stash_ref "$@" @@ -434,20 +431,17 @@ drop_stash () { } apply_to_branch () { - have_stash || die 'Nothing to apply' - test -n "$1" || die 'No branch name specified' branch=$1 + shift 1 - if test -z "$2" - then - set x "$ref_stash@{0}" - fi - stash=$2 + set -- --index "$@" + assert_stash_like "$@" - git checkout -b $branch $stash^ && - apply_stash --index $stash && - drop_stash $stash + git checkout -b $branch $REV^ && + apply_stash "$@" + + test -z "$IS_STASH_REF" || drop_stash "$@" } PARSE_CACHE='--not-parsed' @@ -498,10 +492,7 @@ drop) ;; pop) shift - if apply_stash "$@" - then - drop_stash "$applied_stash" - fi + pop_stash "$@" ;; branch) shift