summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>2020-02-17 17:25:21 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-02-19 10:56:49 -0800
commit8c3713cede71e4741dac546f787734627329f55b (patch)
tree41eddf353ac3f6cbeca3e81c86536278712cb58a /t
parentdoc: stash: synchronize <pathspec> description (diff)
downloadtgif-8c3713cede71e4741dac546f787734627329f55b.tar.xz
stash: eliminate crude option parsing
Eliminate crude option parsing and rely on real parsing instead, because 1) Crude parsing is crude, for example it's not capable of handling things like `git stash -m Message` 2) Adding options in two places is inconvenient and prone to bugs As a side result, the case of `git stash -m Message` gets fixed. Also give a good error message instead of just throwing usage at user. ---- Some review of what's been happening to this code: Before [1], `git-stash.sh` only verified that all args begin with `-` : # The default command is "push" if nothing but options are given seen_non_option= for opt do case "$opt" in --) break ;; -*) ;; *) seen_non_option=t; break ;; esac done Later, [1] introduced the duplicate code I'm now removing, also making the previous test more strict by white-listing options. ---- [1] Commit 40af1468 ("stash: convert `stash--helper.c` into `stash.c`" 2019-02-26) Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3903-stash.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index ea56e85e70..3ad23e2502 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -285,6 +285,11 @@ test_expect_success 'stash --no-keep-index' '
test bar,bar2 = $(cat file),$(cat file2)
'
+test_expect_success 'dont assume push with non-option args' '
+ test_must_fail git stash -q drop 2>err &&
+ test_i18ngrep -e "subcommand wasn'\''t specified; '\''push'\'' can'\''t be assumed due to unexpected token '\''drop'\''" err
+'
+
test_expect_success 'stash --invalid-option' '
echo bar5 >file &&
echo bar6 >file2 &&