X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-stash.sh;h=908aab2659ca5d66d8091e474c484dd8d9b88c0c;hb=cd4ce1e8a81ef5c24af7b914fb72212273e7d489;hp=aa47e541ee4fe55254edc3fb59ef534ba4d5be66;hpb=c24138bc55bcbbde2ea8601c504752e5a39f53f2;p=git.git diff --git a/git-stash.sh b/git-stash.sh index aa47e541e..908aab265 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -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 @@ -210,14 +210,18 @@ 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 }