]> git.ipfire.org Git - thirdparty/git.git/commit
stash: allow "git stash [<options>] --patch <pathspec>" to assume push
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Sat, 7 Jun 2025 09:45:26 +0000 (10:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 7 Jun 2025 17:37:17 +0000 (10:37 -0700)
commit468817bab2ab5fd9b71a8df49e02b8d5521b1631
treebf22715d92d4e35794cd3104ffeedcacb60d01ca
parente6659b77dfed6f3778e5c6870927be3da082d4f5
stash: allow "git stash [<options>] --patch <pathspec>" to assume push

The support for assuming "push" when "-p" is given introduced in
9e140909f61 (stash: allow pathspecs in the no verb form, 2017-02-28) is
very narrow, neither "git stash -m <message> -p <pathspec>" nor "git
stash --patch <pathspec>" imply "push" and die instead. Relax this by
passing PARSE_OPT_STOP_AT_NON_OPTION when push is being assumed and then
setting "force_assume" if "--patch" was present. This means "git stash
<pathspec> -p" still dies so that it does not assume the user meant
"push" if they mistype a subcommand name but "git stash -m <message> -p
<pathspec>" will now succeed. The test added in the last commit is
adjusted to check that push is still assumed when "--patch" comes after
other options on the command-line.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stash.c
t/t3903-stash.sh