Merge branch 'jc/prompt-upstream'
An enhancement to the GIT_PS1_SHOWUPSTREAM facility. * jc/prompt-upstream: git-prompt.sh: optionally show upstream branch name
This commit is contained in:
@ -60,6 +60,7 @@
|
|||||||
# of values:
|
# of values:
|
||||||
#
|
#
|
||||||
# verbose show number of commits ahead/behind (+/-) upstream
|
# verbose show number of commits ahead/behind (+/-) upstream
|
||||||
|
# name if verbose, then also show the upstream abbrev name
|
||||||
# legacy don't use the '--count' option available in recent
|
# legacy don't use the '--count' option available in recent
|
||||||
# versions of git-rev-list
|
# versions of git-rev-list
|
||||||
# git always compare HEAD to @{upstream}
|
# git always compare HEAD to @{upstream}
|
||||||
@ -94,7 +95,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=""
|
local upstream=git legacy="" verbose="" name=""
|
||||||
|
|
||||||
svn_remote=()
|
svn_remote=()
|
||||||
# get some config options from git-config
|
# get some config options from git-config
|
||||||
@ -122,6 +123,7 @@ __git_ps1_show_upstream ()
|
|||||||
git|svn) upstream="$option" ;;
|
git|svn) upstream="$option" ;;
|
||||||
verbose) verbose=1 ;;
|
verbose) verbose=1 ;;
|
||||||
legacy) legacy=1 ;;
|
legacy) legacy=1 ;;
|
||||||
|
name) name=1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -204,6 +206,9 @@ __git_ps1_show_upstream ()
|
|||||||
*) # diverged from upstream
|
*) # diverged from upstream
|
||||||
p=" u+${count#* }-${count% *}" ;;
|
p=" u+${count#* }-${count% *}" ;;
|
||||||
esac
|
esac
|
||||||
|
if [[ -n "$count" && -n "$name" ]]; then
|
||||||
|
p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user