]> git.ipfire.org Git - thirdparty/git.git/commit
stash: allow "git stash -p <pathspec>" to assume push again
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Sat, 7 Jun 2025 09:45:25 +0000 (10:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 7 Jun 2025 17:37:16 +0000 (10:37 -0700)
commite6659b77dfed6f3778e5c6870927be3da082d4f5
tree3a49eac7cde784f53d377ff3e0e61c6388b95495
parent8613c2bb6cd16ef530dc5dd74d3b818a1ccbf1c0
stash: allow "git stash -p <pathspec>" to assume push again

Historically "git stash [<options>]" was assumed to mean "git stash save
[<options>]". Since 1ada5020b38 (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, 9e140909f61 (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 in 8c3713cede7
(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>
builtin/stash.c
t/t3903-stash.sh