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>
This commit is contained in:
parent
dab1b7905d
commit
4d9dc2c57a
@ -115,7 +115,7 @@ __git_ps1_show_upstream ()
|
|||||||
{
|
{
|
||||||
local key value
|
local key value
|
||||||
local svn_remote svn_url_pattern count n
|
local svn_remote svn_url_pattern count n
|
||||||
local upstream=git legacy="" verbose="" name=""
|
local upstream_type=git legacy="" verbose="" name=""
|
||||||
|
|
||||||
svn_remote=()
|
svn_remote=()
|
||||||
# get some config options from git-config
|
# get some config options from git-config
|
||||||
@ -132,7 +132,7 @@ __git_ps1_show_upstream ()
|
|||||||
svn-remote.*.url)
|
svn-remote.*.url)
|
||||||
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
|
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
|
||||||
svn_url_pattern="$svn_url_pattern\\|$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
|
esac
|
||||||
done <<< "$output"
|
done <<< "$output"
|
||||||
@ -141,16 +141,16 @@ __git_ps1_show_upstream ()
|
|||||||
local option
|
local option
|
||||||
for option in ${GIT_PS1_SHOWUPSTREAM}; do
|
for option in ${GIT_PS1_SHOWUPSTREAM}; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
git|svn) upstream="$option" ;;
|
git|svn) upstream_type="$option" ;;
|
||||||
verbose) verbose=1 ;;
|
verbose) verbose=1 ;;
|
||||||
legacy) legacy=1 ;;
|
legacy) legacy=1 ;;
|
||||||
name) name=1 ;;
|
name) name=1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Find our upstream
|
# Find our upstream type
|
||||||
case "$upstream" in
|
case "$upstream_type" in
|
||||||
git) upstream="@{upstream}" ;;
|
git) upstream_type="@{upstream}" ;;
|
||||||
svn*)
|
svn*)
|
||||||
# get the upstream from the "git-svn-id: ..." in a commit message
|
# get the upstream from the "git-svn-id: ..." in a commit message
|
||||||
# (git-svn uses essentially the same procedure internally)
|
# (git-svn uses essentially the same procedure internally)
|
||||||
@ -167,12 +167,12 @@ __git_ps1_show_upstream ()
|
|||||||
|
|
||||||
if [[ -z "$svn_upstream" ]]; then
|
if [[ -z "$svn_upstream" ]]; then
|
||||||
# default branch name for checkouts with no layout:
|
# default branch name for checkouts with no layout:
|
||||||
upstream=${GIT_SVN_ID:-git-svn}
|
upstream_type=${GIT_SVN_ID:-git-svn}
|
||||||
else
|
else
|
||||||
upstream=${svn_upstream#/}
|
upstream_type=${svn_upstream#/}
|
||||||
fi
|
fi
|
||||||
elif [[ "svn+git" = "$upstream" ]]; then
|
elif [[ "svn+git" = "$upstream_type" ]]; then
|
||||||
upstream="@{upstream}"
|
upstream_type="@{upstream}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -180,11 +180,11 @@ __git_ps1_show_upstream ()
|
|||||||
# Find how many commits we are ahead/behind our upstream
|
# Find how many commits we are ahead/behind our upstream
|
||||||
if [[ -z "$legacy" ]]; then
|
if [[ -z "$legacy" ]]; then
|
||||||
count="$(git rev-list --count --left-right \
|
count="$(git rev-list --count --left-right \
|
||||||
"$upstream"...HEAD 2>/dev/null)"
|
"$upstream_type"...HEAD 2>/dev/null)"
|
||||||
else
|
else
|
||||||
# produce equivalent output to --count for older versions of git
|
# produce equivalent output to --count for older versions of git
|
||||||
local commits
|
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
|
then
|
||||||
local commit behind=0 ahead=0
|
local commit behind=0 ahead=0
|
||||||
for commit in $commits
|
for commit in $commits
|
||||||
@ -229,7 +229,7 @@ __git_ps1_show_upstream ()
|
|||||||
esac
|
esac
|
||||||
if [[ -n "$count" && -n "$name" ]]; then
|
if [[ -n "$count" && -n "$name" ]]; then
|
||||||
__git_ps1_upstream_name=$(git rev-parse \
|
__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
|
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
||||||
p="$p \${__git_ps1_upstream_name}"
|
p="$p \${__git_ps1_upstream_name}"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user