Skip to content

Commit 8ab404e

Browse files
committed
Merge branch 'ab/do-not-limit-stash-help-to-push'
"git stash" by default triggers its "push" action, but its implementation also made "git stash -h" to show short help only for "git stash push", which has been corrected. * ab/do-not-limit-stash-help-to-push: stash: don't show "git stash push" usage on bad "git stash" usage
2 parents 077e120 + ca7990c commit 8ab404e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

builtin/stash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,
16831683
if (argc) {
16841684
force_assume = !strcmp(argv[0], "-p");
16851685
argc = parse_options(argc, argv, prefix, options,
1686+
push_assumed ? git_stash_usage :
16861687
git_stash_push_usage,
16871688
PARSE_OPT_KEEP_DASHDASH);
16881689
}

t/t3903-stash.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

1111
. ./test-lib.sh
1212

13+
test_expect_success 'usage on cmd and subcommand invalid option' '
14+
test_expect_code 129 git stash --invalid-option 2>usage &&
15+
grep "or: git stash" usage &&
16+
17+
test_expect_code 129 git stash push --invalid-option 2>usage &&
18+
! grep "or: git stash" usage
19+
'
20+
21+
test_expect_success 'usage on main command -h emits a summary of subcommands' '
22+
test_expect_code 129 git stash -h >usage &&
23+
grep -F "usage: git stash list" usage &&
24+
grep -F "or: git stash show" usage
25+
'
26+
27+
test_expect_failure 'usage for subcommands should emit subcommand usage' '
28+
test_expect_code 129 git stash push -h >usage &&
29+
grep -F "usage: git stash [push" usage
30+
'
31+
1332
diff_cmp () {
1433
for i in "$1" "$2"
1534
do

0 commit comments

Comments
 (0)