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 () {
219
219
-a|--all)
220
220
untracked=all
221
221
;;
222
+ --help)
223
+ show_help
224
+ ;;
222
225
--)
223
226
shift
224
227
break
@@ -301,11 +304,17 @@ list_stash () {
301
304
}
302
305
303
306
show_stash () {
307
+ ALLOW_UNKNOWN_FLAGS=t
304
308
assert_stash_like " $@ "
305
309
306
310
git diff ${FLAGS:- --stat} $b_commit $w_commit
307
311
}
308
312
313
+ show_help () {
314
+ exec git help stash
315
+ exit 1
316
+ }
317
+
309
318
#
310
319
# Parses the remaining options looking for flags and
311
320
# at most one revision defaulting to ${ref_stash}@{0}
@@ -332,13 +341,14 @@ show_stash () {
332
341
#
333
342
# GIT_QUIET is set to t if -q is specified
334
343
# 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)
336
345
#
337
346
# dies if:
338
347
# * too many revisions specified
339
348
# * no revision is specified and there is no stash stack
340
349
# * a revision is specified which cannot be resolve to a SHA1
341
350
# * a non-existent stash reference is specified
351
+ # * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t"
342
352
#
343
353
344
354
parse_flags_and_rev ()
@@ -371,7 +381,12 @@ parse_flags_and_rev()
371
381
--index)
372
382
INDEX_OPTION=--index
373
383
;;
384
+ --help)
385
+ show_help
386
+ ;;
374
387
-* )
388
+ test " $ALLOW_UNKNOWN_FLAGS " = t ||
389
+ die " $( eval_gettext " unknown option: \$ opt" ) "
375
390
FLAGS=" ${FLAGS}${FLAGS: + } $opt "
376
391
;;
377
392
esac
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ test_expect_success 'unstashing in a subdirectory' '
100
100
)
101
101
'
102
102
103
+ test_expect_success ' stash drop complains of extra options' '
104
+ test_must_fail git stash drop --foo
105
+ '
106
+
103
107
test_expect_success ' drop top stash' '
104
108
git reset --hard &&
105
109
git stash list > stashlist1 &&
You can’t perform that action at this time.
0 commit comments