Skip to content

Commit a9bf09e

Browse files
jonseymourgitster
authored andcommitted
detached-stash: simplify git stash show
This commit refactors git stash show to make use of the assert_stash_like function. git show now dies if the presented argument is non-stash-like. Previous behaviour was to tolerate commits that were not even stash-like. Previously, git stash show would accept stash-like arguments, but only if there was a stash on the stack. Now, git stash accepts stash-like arguments always and only fails if no stash-like argument is specified and there is no stash stack. Signed-off-by: Jon Seymour <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb433dc commit a9bf09e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

git-stash.sh

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

212212
show_stash () {
213-
have_stash || die 'No stash found'
214-
215-
flags=$(git rev-parse --no-revs --flags "$@")
216-
if test -z "$flags"
217-
then
218-
flags=--stat
219-
fi
220-
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"
213+
assert_stash_like "$@"
224214

225-
git diff $flags $b_commit $w_commit
215+
git diff ${FLAGS:---stat} $b_commit $w_commit
226216
}
227217

228218
#

0 commit comments

Comments
 (0)