From 2bb066eed54711434444a11c5580bbf4238908fa Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 7 Apr 2012 19:16:51 -0700 Subject: [PATCH] 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. --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index 444b30f3d..17b05d59d 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -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 }