diff options
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-x | git-stash.sh | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/git-stash.sh b/git-stash.sh index f796c2fe24..908aab2659 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -7,7 +7,7 @@ USAGE="list [<options>] or: $dashless drop [-q|--quiet] [<stash>] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>] or: $dashless branch <branchname> [<stash>] - or: $dashless [save [-k|--keep-index] [-q|--quiet] [<message>]] + or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [<message>]] or: $dashless clear" SUBDIRECTORY_OK=Yes @@ -57,7 +57,7 @@ create_stash () { # state of the base commit if b_commit=$(git rev-parse --verify HEAD) then - head=$(git log --no-color --abbrev-commit --pretty=oneline -n 1 HEAD --) + head=$(git rev-list --oneline -n 1 HEAD --) else die "You do not have the initial commit yet" fi @@ -151,6 +151,7 @@ save_stash () { ;; -*) echo "error: unknown option for 'stash save': $1" + echo " To provide a message, use git stash save -- '$1'" usage ;; *) @@ -209,18 +210,23 @@ 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 --verify --default $ref_stash "$@") && - b_commit=$(git rev-parse --verify "$w_commit^") && + w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") && + b_commit=$(git rev-parse --quiet --verify "$w_commit^") || + die "'$*' is not a stash" + git diff $flags $b_commit $w_commit } apply_stash () { + applied_stash= unstash_index= while test $# != 0 @@ -242,6 +248,9 @@ apply_stash () { if test $# = 0 then have_stash || die 'Nothing to apply' + applied_stash="$ref_stash@{0}" + else + applied_stash="$*" fi # stash records the work tree, and is a merge between the @@ -415,8 +424,7 @@ pop) shift if apply_stash "$@" then - test -z "$unstash_index" || shift - drop_stash "$@" + drop_stash "$applied_stash" fi ;; branch) |