diff options
-rw-r--r-- | builtin/stash.c | 1 | ||||
-rwxr-xr-x | t/t3903-stash.sh | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index fb1e466e5d..6da736d718 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1683,6 +1683,7 @@ static int push_stash(int argc, const char **argv, const char *prefix, if (argc) { force_assume = !strcmp(argv[0], "-p"); argc = parse_options(argc, argv, prefix, options, + push_assumed ? git_stash_usage : git_stash_push_usage, PARSE_OPT_KEEP_DASHDASH); } diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 2c66cfbc3b..b17c52d880 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -10,6 +10,25 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +test_expect_success 'usage on cmd and subcommand invalid option' ' + test_expect_code 129 git stash --invalid-option 2>usage && + grep "or: git stash" usage && + + test_expect_code 129 git stash push --invalid-option 2>usage && + ! grep "or: git stash" usage +' + +test_expect_success 'usage on main command -h emits a summary of subcommands' ' + test_expect_code 129 git stash -h >usage && + grep -F "usage: git stash list" usage && + grep -F "or: git stash show" usage +' + +test_expect_failure 'usage for subcommands should emit subcommand usage' ' + test_expect_code 129 git stash push -h >usage && + grep -F "usage: git stash [push" usage +' + diff_cmp () { for i in "$1" "$2" do |