From e2f2489a666caf238804783b4e8851a781ac6ffc Mon Sep 17 00:00:00 2001 From: Joseph Heyburn <34041368+jdheyburn@users.noreply.github.com> Date: Tue, 8 Dec 2020 17:25:42 +0000 Subject: [PATCH] fix(git): silently fail in `git_main_branch` if not in a git repo (#9484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index bf2619976..e32136f15 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -31,6 +31,7 @@ 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