All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Justin Donnelly via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Justin Donnelly" <justinrdonnelly@gmail.com>,
	"Justin Donnelly" <justinrdonnelly@gmail.com>
Subject: [PATCH v2 1/4] git-prompt: rename `upstream` to `upstream_type`
Date: Sun, 27 Feb 2022 19:57:09 +0000	[thread overview]
Message-ID: <1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645991832.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1162.v2.git.1645991832.gitgitgadget@gmail.com>

From: Justin Donnelly <justinrdonnelly@gmail.com>

In `__git_ps1_show_upstream` rename the variable `upstream` to
`upstream_type`. This allows `__git_ps1_show_upstream` to reference a
variable named `upstream` that is declared `local` in `__git_ps1`, which
calls `__git_ps1_show_upstream`.

Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>
---
 contrib/completion/git-prompt.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index db7c0068fb5..3997e099aa7 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -115,7 +115,7 @@ __git_ps1_show_upstream ()
 {
 	local key value
 	local svn_remote svn_url_pattern count n
-	local upstream=git legacy="" verbose="" name=""
+	local upstream_type=git legacy="" verbose="" name=""
 
 	svn_remote=()
 	# get some config options from git-config
@@ -132,7 +132,7 @@ __git_ps1_show_upstream ()
 		svn-remote.*.url)
 			svn_remote[$((${#svn_remote[@]} + 1))]="$value"
 			svn_url_pattern="$svn_url_pattern\\|$value"
-			upstream=svn+git # default upstream is SVN if available, else git
+			upstream_type=svn+git # default upstream type is SVN if available, else git
 			;;
 		esac
 	done <<< "$output"
@@ -141,16 +141,16 @@ __git_ps1_show_upstream ()
 	local option
 	for option in ${GIT_PS1_SHOWUPSTREAM}; do
 		case "$option" in
-		git|svn) upstream="$option" ;;
+		git|svn) upstream_type="$option" ;;
 		verbose) verbose=1 ;;
 		legacy)  legacy=1  ;;
 		name)    name=1 ;;
 		esac
 	done
 
-	# Find our upstream
-	case "$upstream" in
-	git)    upstream="@{upstream}" ;;
+	# Find our upstream type
+	case "$upstream_type" in
+	git)    upstream_type="@{upstream}" ;;
 	svn*)
 		# get the upstream from the "git-svn-id: ..." in a commit message
 		# (git-svn uses essentially the same procedure internally)
@@ -167,12 +167,12 @@ __git_ps1_show_upstream ()
 
 			if [[ -z "$svn_upstream" ]]; then
 				# default branch name for checkouts with no layout:
-				upstream=${GIT_SVN_ID:-git-svn}
+				upstream_type=${GIT_SVN_ID:-git-svn}
 			else
-				upstream=${svn_upstream#/}
+				upstream_type=${svn_upstream#/}
 			fi
-		elif [[ "svn+git" = "$upstream" ]]; then
-			upstream="@{upstream}"
+		elif [[ "svn+git" = "$upstream_type" ]]; then
+			upstream_type="@{upstream}"
 		fi
 		;;
 	esac
@@ -180,11 +180,11 @@ __git_ps1_show_upstream ()
 	# Find how many commits we are ahead/behind our upstream
 	if [[ -z "$legacy" ]]; then
 		count="$(git rev-list --count --left-right \
-				"$upstream"...HEAD 2>/dev/null)"
+				"$upstream_type"...HEAD 2>/dev/null)"
 	else
 		# produce equivalent output to --count for older versions of git
 		local commits
-		if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
+		if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)"
 		then
 			local commit behind=0 ahead=0
 			for commit in $commits
@@ -229,7 +229,7 @@ __git_ps1_show_upstream ()
 		esac
 		if [[ -n "$count" && -n "$name" ]]; then
 			__git_ps1_upstream_name=$(git rev-parse \
-				--abbrev-ref "$upstream" 2>/dev/null)
+				--abbrev-ref "$upstream_type" 2>/dev/null)
 			if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
 				p="$p \${__git_ps1_upstream_name}"
 			else
-- 
gitgitgadget


  reply	other threads:[~2022-02-27 19:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 11:44 [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 1/4] git-prompt: rename `upstream` to `upstream_type` Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 2/4] git-prompt: make upstream state indicator location consistent Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 3/4] git-prompt: make long upstream state indicator consistent Justin Donnelly via GitGitGadget
2022-02-25 11:44 ` [PATCH 4/4] git-prompt: put upstream comments together Justin Donnelly via GitGitGadget
2022-02-25 12:22 ` [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Ævar Arnfjörð Bjarmason
2022-02-27  0:32   ` Justin Donnelly
2022-02-27 10:19     ` Ævar Arnfjörð Bjarmason
2022-02-27 19:57 ` [PATCH v2 " Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` Justin Donnelly via GitGitGadget [this message]
2022-02-27 19:57   ` [PATCH v2 2/4] git-prompt: make upstream state indicator location consistent Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` [PATCH v2 3/4] git-prompt: make long upstream state indicator consistent Justin Donnelly via GitGitGadget
2022-02-27 19:57   ` [PATCH v2 4/4] git-prompt: put upstream comments together Justin Donnelly via GitGitGadget
2022-03-22 12:25   ` [PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators Ævar Arnfjörð Bjarmason
2022-03-23 20:06     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645991832.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=justinrdonnelly@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.