{"thread":{"id":"53525","subject":"[PATCH] completion: don't override given stash subcommand with -p","startedAt":"2020-05-21T18:36:06Z","lastAt":"2020-05-21T18:36:06Z","messageCount":1,"participants":["Ville Skyttä"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"398381","messageId":"20200521183559.14744-1-ville.skytta@iki.fi","threadId":"53525","inReplyTo":null,"subject":"[PATCH] completion: don't override given stash subcommand with -p","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2020-05-21T18:35:59Z","receivedAt":"2020-05-21T18:36:06Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"df70b190 (completion: make stash -p and alias for stash push -p,\n2018-04-20) wanted to make sure \"git stash -p <TAB>\" offers the same\ncompletion as \"git stash push -p <TAB>\", but it did so by forcing the\n$subcommand to be \"push\" whenever then \"-p\" option is found on the\ncommand line.\n\nThis harms any subcommand that can take the \"-p\" option---even when the\nsubcommand is explicitly given, e.g. \"git stash show -p\", the code added\nby the change would overwrite the $subcommand the user gave us.\n\nFix it by making sure that the defaulting to \"push\" happens only when\nthere is no $subcommand given yet.\n\nSigned-off-by: Ville Skyttä <ville.skytta@iki.fi>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 70ad04e1b2..8dc4ad0e0d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2782,7 +2782,7 @@ _git_stash ()\n \tlocal save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'\n \tlocal subcommands='push list show apply clear drop pop create branch'\n \tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands save\")\"\n-\tif [ -n \"$(__git_find_on_cmdline \"-p\")\" ]; then\n+\tif [ -z \"$subcommand\" -a -n \"$(__git_find_on_cmdline \"-p\")\" ]; then\n \t\tsubcommand=\"push\"\n \tfi\n \tif [ -z \"$subcommand\" ]; then\n-- \n2.27.0.rc1.dirty\n\n"}]}