lib/git.zsh: Avoid calling current_branch()

The original code hard-coded 'origin' as the remote and called
current_branch() to get the corresponding remote branch name,
which may not necessarily be the correct upstream branch.

Use the the built-in @{upstream} syntax instead of calling
current_branch().

This improves performance and fixes a bug when the local and
remote branches do not have the same name.
This commit is contained in:
David Aguilar 2012-04-07 19:16:51 -07:00
commit 2bb066eed5

View file

@ -57,7 +57,7 @@ git_remote_status() {
# Checks if there are commits ahead from remote
function git_prompt_ahead() {
if [[ -n $(git rev-list -1 origin/$(current_branch)..HEAD 2>/dev/null) ]]; then
if [[ -n $(git rev-list -1 --first-parent @{upstream}..HEAD 2>/dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}