Code

t/gitweb-lib.sh: Use tabs for indent consistently
[git.git] / git-stash.sh
index 750f360da9730423fde863de391ecbe550b172cf..7ce818bd1baecfb48447f862bb2654ccbd3cf2ff 100755 (executable)
@@ -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