diff options
-rwxr-xr-x | git-stash.sh | 6 | ||||
-rwxr-xr-x | t/t3903-stash.sh | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/git-stash.sh b/git-stash.sh index d4cf818be9..f540127da3 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -301,6 +301,7 @@ list_stash () { } show_stash () { + ALLOW_UNKNOWN_FLAGS=t assert_stash_like "$@" git diff ${FLAGS:---stat} $b_commit $w_commit @@ -332,13 +333,14 @@ show_stash () { # # GIT_QUIET is set to t if -q is specified # INDEX_OPTION is set to --index if --index is specified. -# FLAGS is set to the remaining flags +# FLAGS is set to the remaining flags (if allowed) # # dies if: # * too many revisions specified # * no revision is specified and there is no stash stack # * a revision is specified which cannot be resolve to a SHA1 # * a non-existent stash reference is specified +# * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t" # parse_flags_and_rev() @@ -372,6 +374,8 @@ parse_flags_and_rev() INDEX_OPTION=--index ;; -*) + test "$ALLOW_UNKNOWN_FLAGS" = t || + die "$(eval_gettext "unknown option: \$opt")" FLAGS="${FLAGS}${FLAGS:+ }$opt" ;; esac diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 1e29962fad..384678953e 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -93,6 +93,10 @@ test_expect_success 'unstashing in a subdirectory' ' ) ' +test_expect_success 'stash drop complains of extra options' ' + test_must_fail git stash drop --foo +' + test_expect_success 'drop top stash' ' git reset --hard && git stash list > stashlist1 && |