[PATCH] completion: fix zsh parsing $GIT_PS1_SHOWUPSTREAM
- From
Thomas via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Apr 25, 2024, 18:59 UTC
- Message-ID
- <pull.1710.git.git.1714071592035.gitgitgadget@gmail.com>
From: Thomas Queiroz <thomasqueirozb@gmail.com>
Since GIT_PS1_SHOWUPSTREAM is a variable with space separated values and zsh for loops do no split by space by default, parsing of the options wasn't actually being done. The `-d' '` is a hacky solution that works in both bash and zsh. The correct way to do that in zsh would be do use read -rA and loop over the resulting array but -A isn't defined in bash.
Signed-off-by: Thomas Queiroz <thomasqueirozb@gmail.com>
---
completion: Fix zsh parsing $GIT_PS1_SHOWUPSTREAMPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1710%2Fthomasqueirozb%2Fzsh-completion-fix-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1710/thomasqueirozb/zsh-completion-fix-v1 Pull-Request: https://github.com/git/git/pull/1710
contrib/completion/git-prompt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 5330e769a72..9c25ec1e965 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -141,14 +141,14 @@ __git_ps1_show_upstream () # parse configuration values local option - for option in ${GIT_PS1_SHOWUPSTREAM-}; do + while read -r -d' ' option; do case "$option" in git|svn) upstream_type="$option" ;; verbose) verbose=1 ;; legacy) legacy=1 ;; name) name=1 ;; esac - done + done <<< "${GIT_PS1_SHOWUPSTREAM-} " # Find our upstream type case "$upstream_type" in base-commit: 21306a098c3f174ad4c2a5cddb9069ee27a548b0
-- gitgitgadget