Skip to content

Commit 4d9dc2c

Browse files
justinrdonnellygitster
authored andcommitted
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 <[email protected]> Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dab1b79 commit 4d9dc2c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

contrib/completion/git-prompt.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ __git_ps1_show_upstream ()
115115
{
116116
local key value
117117
local svn_remote svn_url_pattern count n
118-
local upstream=git legacy="" verbose="" name=""
118+
local upstream_type=git legacy="" verbose="" name=""
119119

120120
svn_remote=()
121121
# get some config options from git-config
@@ -132,7 +132,7 @@ __git_ps1_show_upstream ()
132132
svn-remote.*.url)
133133
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
134134
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
136136
;;
137137
esac
138138
done <<< "$output"
@@ -141,16 +141,16 @@ __git_ps1_show_upstream ()
141141
local option
142142
for option in ${GIT_PS1_SHOWUPSTREAM}; do
143143
case "$option" in
144-
git|svn) upstream="$option" ;;
144+
git|svn) upstream_type="$option" ;;
145145
verbose) verbose=1 ;;
146146
legacy) legacy=1 ;;
147147
name) name=1 ;;
148148
esac
149149
done
150150

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}" ;;
154154
svn*)
155155
# get the upstream from the "git-svn-id: ..." in a commit message
156156
# (git-svn uses essentially the same procedure internally)
@@ -167,24 +167,24 @@ __git_ps1_show_upstream ()
167167

168168
if [[ -z "$svn_upstream" ]]; then
169169
# default branch name for checkouts with no layout:
170-
upstream=${GIT_SVN_ID:-git-svn}
170+
upstream_type=${GIT_SVN_ID:-git-svn}
171171
else
172-
upstream=${svn_upstream#/}
172+
upstream_type=${svn_upstream#/}
173173
fi
174-
elif [[ "svn+git" = "$upstream" ]]; then
175-
upstream="@{upstream}"
174+
elif [[ "svn+git" = "$upstream_type" ]]; then
175+
upstream_type="@{upstream}"
176176
fi
177177
;;
178178
esac
179179

180180
# Find how many commits we are ahead/behind our upstream
181181
if [[ -z "$legacy" ]]; then
182182
count="$(git rev-list --count --left-right \
183-
"$upstream"...HEAD 2>/dev/null)"
183+
"$upstream_type"...HEAD 2>/dev/null)"
184184
else
185185
# produce equivalent output to --count for older versions of git
186186
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)"
188188
then
189189
local commit behind=0 ahead=0
190190
for commit in $commits
@@ -229,7 +229,7 @@ __git_ps1_show_upstream ()
229229
esac
230230
if [[ -n "$count" && -n "$name" ]]; then
231231
__git_ps1_upstream_name=$(git rev-parse \
232-
--abbrev-ref "$upstream" 2>/dev/null)
232+
--abbrev-ref "$upstream_type" 2>/dev/null)
233233
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
234234
p="$p \${__git_ps1_upstream_name}"
235235
else

0 commit comments

Comments
 (0)