Skip to content

Commit 14cd458

Browse files
hendebygitster
authored andcommitted
Improve error messages from 'git stash show'
The previous error message "fatal: Needed a single revision" is not very informative. Signed-off-by: Gustaf Hendeby <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8fcaca3 commit 14cd458

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

git-stash.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,18 @@ list_stash () {
210210
}
211211

212212
show_stash () {
213+
have_stash || die 'No stash found'
214+
213215
flags=$(git rev-parse --no-revs --flags "$@")
214216
if test -z "$flags"
215217
then
216218
flags=--stat
217219
fi
218220

219-
w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
220-
b_commit=$(git rev-parse --verify "$w_commit^") &&
221+
w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
222+
b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
223+
die "'$*' is not a stash"
224+
221225
git diff $flags $b_commit $w_commit
222226
}
223227

0 commit comments

Comments
 (0)