diff options
author | Vitaly Polonetsky <m_vitaly@topixoft.com> | 2021-09-03 02:43:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 11:43:53 +0200 |
commit | 53b54f5faa271ee90ec31fcffb559541c82b9703 (patch) | |
tree | 6df715bb767027cdaa769d3fb4fa39dbb063c5e6 /plugins | |
parent | 21b385e7bd522983642b52b51db5d4a210a77717 (diff) | |
download | zsh-53b54f5faa271ee90ec31fcffb559541c82b9703.tar.gz zsh-53b54f5faa271ee90ec31fcffb559541c82b9703.tar.bz2 zsh-53b54f5faa271ee90ec31fcffb559541c82b9703.zip |
feat(git): guess main branch name also from remotes (#10158)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/git/git.plugin.zsh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f0d9aaedc..2985ba024 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -32,10 +32,10 @@ function work_in_progress() { # Check if main exists and use instead of master function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return - local branch - for branch in main trunk; do - if command git show-ref -q --verify refs/heads/$branch; then - echo $branch + local ref + for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do + if command git show-ref -q --verify $ref; then + echo ${ref:t} return fi done |