diff options
author | Marc Cornellà <marc.cornella@live.com> | 2015-12-15 02:34:59 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2015-12-15 02:34:59 +0100 |
commit | e344f4c0662bde84e720e723ab4a445df03e5100 (patch) | |
tree | 7ce74d24f825e184508ed0872a3899104e60cfc4 /plugins | |
parent | bfd2d8de24fc1ac9663f77a2fdffe40a403eefb7 (diff) | |
parent | 9f552130bd0c390420a51bbfd2933c065a1581d0 (diff) | |
download | zsh-e344f4c0662bde84e720e723ab4a445df03e5100.tar.gz zsh-e344f4c0662bde84e720e723ab4a445df03e5100.tar.bz2 zsh-e344f4c0662bde84e720e723ab4a445df03e5100.zip |
Merge pull request #4420 from apjanke/git-move-current_branch-to-core
Git: move current_branch() to core
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/git/git.plugin.zsh | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d78b82df3..b851fb97d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -6,19 +6,12 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd # Functions # -# The current branch name -# Usage example: git pull origin $(current_branch) -# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if -# it's not a symbolic ref, but in a Git repo. +# The name of the current branch +# Back-compatibility wrapper for when this function was defined here in +# the plugin, before being pulled in to core lib/git.zsh as git_current_branch() +# to fix the core -> git plugin dependency. function current_branch() { - local ref - ref=$($_omz_git_git_cmd symbolic-ref --quiet HEAD 2> /dev/null) - local ret=$? - if [[ $ret != 0 ]]; then - [[ $ret == 128 ]] && return # no git repo. - ref=$($_omz_git_git_cmd rev-parse --short HEAD 2> /dev/null) || return - fi - echo ${ref#refs/heads/} + git_current_branch } # The list of remotes function current_repository() { @@ -99,7 +92,7 @@ alias gfo='git fetch origin' alias gg='git gui citool' alias gga='git gui citool --amend' ggf() { -[[ "$#" != 1 ]] && local b="$(current_branch)" +[[ "$#" != 1 ]] && local b="$(git_current_branch)" git push --force origin "${b:=$1}" } compdef _git ggf=git-checkout @@ -107,23 +100,23 @@ ggl() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git pull origin "${*}" else -[[ "$#" == 0 ]] && local b="$(current_branch)" +[[ "$#" == 0 ]] && local b="$(git_current_branch)" git pull origin "${b:=$1}" fi } compdef _git ggl=git-checkout -alias ggpull='git pull origin $(current_branch)' +alias ggpull='git pull origin $(git_current_branch)' compdef _git ggpull=git-checkout ggp() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git push origin "${*}" else -[[ "$#" == 0 ]] && local b="$(current_branch)" +[[ "$#" == 0 ]] && local b="$(git_current_branch)" git push origin "${b:=$1}" fi } compdef _git ggp=git-checkout -alias ggpush='git push origin $(current_branch)' +alias ggpush='git push origin $(git_current_branch)' compdef _git ggpush=git-checkout ggpnp() { if [[ "$#" == 0 ]]; then @@ -133,9 +126,9 @@ ggl "${*}" && ggp "${*}" fi } compdef _git ggpnp=git-checkout -alias ggsup='git branch --set-upstream-to=origin/$(current_branch)' +alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' ggu() { -[[ "$#" != 1 ]] && local b="$(current_branch)" +[[ "$#" != 1 ]] && local b="$(git_current_branch)" git pull --rebase origin "${b:=$1}" } compdef _git ggu=git-checkout |