add function to determine current upstream

for git_prompt_ahead() (in lib/git.zsh) to work with remotes different
than 'origin', we need a way to determine the origin of the currently
active branch.

This uses git-config to find the current branches remote (if any)
This commit is contained in:
Philip Hofstetter 2011-12-28 14:59:55 +01:00
commit 22cf85c0f8

View file

@ -52,6 +52,11 @@ function current_branch() {
echo ${ref#refs/heads/} echo ${ref#refs/heads/}
} }
function git_current_upstream(){
local upstream=$(git config --get branch."$(current_branch)".remote) || return
echo $upstream
}
# these aliases take advantage of the previous function # these aliases take advantage of the previous function
alias ggpull='git pull origin $(current_branch)' alias ggpull='git pull origin $(current_branch)'
compdef ggpull=git compdef ggpull=git