1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-18 10:22:00 +00:00

feat(git): guess main branch name also from remotes (#10158)

Co-authored-by: Marc Cornellà <hello@mcornella.com>
This commit is contained in:
Vitaly Polonetsky 2021-09-03 02:43:53 -07:00 committed by GitHub
parent 21b385e7bd
commit 53b54f5faa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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