git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-prompt.sh: make `option` a local variable

From
SGSibo Dong via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 31, 2020, 22:09 UTC
Message-ID
<pull.775.git.1604182187195.gitgitgadget@gmail.com>
From: Sibo Dong <sibo.dong@outlook.com>

Other variables like `key` and `value` are local to this completion script, so I think the same should be done with `option`.

Signed-off-by: Sibo Dong <sibo.dong@outlook.com>
---
    git-prompt.sh: make option a local variable
    
    This is very trivial, but variables like key and value are local to 
    git-prompt.sh, so I think the same should be done with option. I have 
    GIT_PS1_SHOW_UPSTREAM set to verbose in my ~/.bashrc, so option gets set
    to verbose in my Bash session whenever I change directories to a local
    repository with a remote.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-775%2Fdongsibo%2Ffix-git-prompt-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-775/dongsibo/fix-git-prompt-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/775
 contrib/completion/git-prompt.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 16260bab73..5116016d39 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -137,6 +137,7 @@ __git_ps1_show_upstream ()
 	done <<< "$output"
 
 	# parse configuration values
+	local option
 	for option in ${GIT_PS1_SHOWUPSTREAM}; do
 		case "$option" in
 		git|svn) upstream="$option" ;;

base-commit: 898f80736c75878acc02dc55672317fcc0e0a5a6
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 4 in “git-prompt.sh: make `option` a local variable”
  1. git-prompt.sh: make `option` a local variableSibo Dong via GitGitGadget, Oct 31, 2020
  2. Junio C HamanoOct 31, 2020
  3. Sibo DongNov 1, 2020
  4. Junio C HamanoNov 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.