stash: allow "git stash -p <pathspec>" to assume push again
Historically "git stash [<options>]" was assumed to mean "git stash save [<options>]". Since1ada5020b3(stash: use stash_push for no verb form, 2017-02-28) it is assumed to mean "git stash push [<options>]". As the push subcommand supports pathspecs,9e140909f6(stash: allow pathspecs in the no verb form, 2017-02-28) allowed "git stash -p <pathspec>" to mean "git stash push -p <pathspec>". This was broken in8c3713cede(stash: eliminate crude option parsing, 2020-02-17) which failed to account for "push" being added to the start of argv in cmd_stash() before it calls push_stash() and kept looking in argv[0] for "-p" after moving the code to push_stash(). Fix this by regression by checking argv[1] instead of argv[0] and add a couple of tests to prevent future regressions. Helped-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8613c2bb6c
commit
e6659b77df
@@ -1789,7 +1789,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,
|
||||
int ret;
|
||||
|
||||
if (argc) {
|
||||
force_assume = !strcmp(argv[0], "-p");
|
||||
force_assume = argc > 1 && !strcmp(argv[1], "-p");
|
||||
argc = parse_options(argc, argv, prefix, options,
|
||||
push_assumed ? git_stash_usage :
|
||||
git_stash_push_usage,
|
||||
|
||||
Reference in New Issue
Block a user