1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-12 08:50:08 +00:00

fix(git): silently fail in git_main_branch if not in a git repo (#9484)

Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
Joseph Heyburn 2020-12-08 17:25:42 +00:00 committed by GitHub
parent 452586e79a
commit e2f2489a66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,7 @@ function work_in_progress() {
# Check if main exists and use instead of master # Check if main exists and use instead of master
function git_main_branch() { function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local branch local branch
for branch in main trunk; do for branch in main trunk; do
if command git show-ref -q --verify refs/heads/$branch; then if command git show-ref -q --verify refs/heads/$branch; then