#autoload

# custom git-completions
__git_command_successful() {
  if (( ${#pipestatus:#0} > 0 )); then
    _message 'not a git repository'
    return 1
  fi
  return 0
}
__git_branch_names() {
  local expl
  declare -a branch_names
  branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
  __git_command_successful || return
  _wanted branch-names expl branch-name compadd $* - $branch_names
}
compdef __git_branch_names branch br
