File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,9 @@ save_stash () {
219219 -a|--all)
220220 untracked=all
221221 ;;
222+ --help)
223+ show_help
224+ ;;
222225 --)
223226 shift
224227 break
@@ -301,11 +304,17 @@ list_stash () {
301304}
302305
303306show_stash () {
307+ ALLOW_UNKNOWN_FLAGS=t
304308 assert_stash_like " $@ "
305309
306310 git diff ${FLAGS:- --stat} $b_commit $w_commit
307311}
308312
313+ show_help () {
314+ exec git help stash
315+ exit 1
316+ }
317+
309318#
310319# Parses the remaining options looking for flags and
311320# at most one revision defaulting to ${ref_stash}@{0}
@@ -332,13 +341,14 @@ show_stash () {
332341#
333342# GIT_QUIET is set to t if -q is specified
334343# INDEX_OPTION is set to --index if --index is specified.
335- # FLAGS is set to the remaining flags
344+ # FLAGS is set to the remaining flags (if allowed)
336345#
337346# dies if:
338347# * too many revisions specified
339348# * no revision is specified and there is no stash stack
340349# * a revision is specified which cannot be resolve to a SHA1
341350# * a non-existent stash reference is specified
351+ # * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t"
342352#
343353
344354parse_flags_and_rev ()
@@ -371,7 +381,12 @@ parse_flags_and_rev()
371381 --index)
372382 INDEX_OPTION=--index
373383 ;;
384+ --help)
385+ show_help
386+ ;;
374387 -* )
388+ test " $ALLOW_UNKNOWN_FLAGS " = t ||
389+ die " $( eval_gettext " unknown option: \$ opt" ) "
375390 FLAGS=" ${FLAGS}${FLAGS: + } $opt "
376391 ;;
377392 esac
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ test_expect_success 'unstashing in a subdirectory' '
100100 )
101101'
102102
103+ test_expect_success ' stash drop complains of extra options' '
104+ test_must_fail git stash drop --foo
105+ '
106+
103107test_expect_success ' drop top stash' '
104108 git reset --hard &&
105109 git stash list > stashlist1 &&
You can’t perform that action at this time.
0 commit comments