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 <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jon Seymour committed
Aug 21, 2010 at 14:09 UTC
a9bf09e19d9ca35e67cd6c5a145fd0e778af82f0
1 file changed
+2
-12
git-stash.sh
+2
-12
@@ -210,19 +210,9 @@ list_stash () {
210
}
211
212
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 "$@"
214
225
- git diff $flags $b_commit $w_commit
215
+ git diff ${FLAGS:---stat} $b_commit $w_commit
216
}
217
218
#