git-prompt: rename `upstream` to `upstream_type`
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> Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Justin Donnelly committed
Feb 27, 2022 at 19:57 UTC
4d9dc2c57a36027a619c3b846cce5f02206d9a06
1 file changed
+13
-13
contrib/completion/git-prompt.sh
+13
-13
@@ -115,7 +115,7 @@ __git_ps1_show_upstream ()
115
{
116
local key value
117
local svn_remote svn_url_pattern count n
118
- local upstream=git legacy="" verbose="" name=""
118
+ local upstream_type=git legacy="" verbose="" name=""
119
120
svn_remote=()
121
# get some config options from git-config
@@ -132,7 +132,7 @@ __git_ps1_show_upstream ()
132
svn-remote.*.url)
133
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
134
svn_url_pattern="$svn_url_pattern\\|$value"
135
- upstream=svn+git # default upstream is SVN if available, else git
135
+ upstream_type=svn+git # default upstream type is SVN if available, else git
136
;;
137
esac
138
done <<< "$output"
@@ -141,16 +141,16 @@ __git_ps1_show_upstream ()
141
local option
142
for option in ${GIT_PS1_SHOWUPSTREAM}; do
143
case "$option" in
144
- git|svn) upstream="$option" ;;
144
+ git|svn) upstream_type="$option" ;;
145
verbose) verbose=1 ;;
146
legacy) legacy=1 ;;
147
name) name=1 ;;
148
esac
149
done
150
151
- # Find our upstream
152
- case "$upstream" in
153
- git) upstream="@{upstream}" ;;
151
+ # Find our upstream type
152
+ case "$upstream_type" in
153
+ git) upstream_type="@{upstream}" ;;
154
svn*)
155
# get the upstream from the "git-svn-id: ..." in a commit message
156
# (git-svn uses essentially the same procedure internally)
@@ -167,12 +167,12 @@ __git_ps1_show_upstream ()
167
168
if [[ -z "$svn_upstream" ]]; then
169
# default branch name for checkouts with no layout:
170
- upstream=${GIT_SVN_ID:-git-svn}
170
+ upstream_type=${GIT_SVN_ID:-git-svn}
171
else
172
- upstream=${svn_upstream#/}
172
+ upstream_type=${svn_upstream#/}
173
fi
174
- elif [[ "svn+git" = "$upstream" ]]; then
175
- upstream="@{upstream}"
174
+ elif [[ "svn+git" = "$upstream_type" ]]; then
175
+ upstream_type="@{upstream}"
176
fi
177
;;
178
esac
@@ -180,11 +180,11 @@ __git_ps1_show_upstream ()
180
# Find how many commits we are ahead/behind our upstream
181
if [[ -z "$legacy" ]]; then
182
count="$(git rev-list --count --left-right \
183
- "$upstream"...HEAD 2>/dev/null)"
183
+ "$upstream_type"...HEAD 2>/dev/null)"
184
else
185
# produce equivalent output to --count for older versions of git
186
local commits
187
- if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
187
+ if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)"
188
then
189
local commit behind=0 ahead=0
190
for commit in $commits
@@ -229,7 +229,7 @@ __git_ps1_show_upstream ()
229
esac
230
if [[ -n "$count" && -n "$name" ]]; then
231
__git_ps1_upstream_name=$(git rev-parse \
232
- --abbrev-ref "$upstream" 2>/dev/null)
232
+ --abbrev-ref "$upstream_type" 2>/dev/null)
233
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
234
p="$p \${__git_ps1_upstream_name}"
235
else