X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=detached-head%2Ffix-detached-head;h=44b98443da82158f004c3a34239bc22b0d2b2d21;hb=21a0b81256c2b571a7d0ce21886b6588af2f25ca;hp=7be050aad8cf177ab93848786c112f2571220282;hpb=0f2ee1cb405df27ca3d71d6794e16e617187e97d;p=git-scripts.git diff --git a/detached-head/fix-detached-head b/detached-head/fix-detached-head index 7be050a..44b9844 100755 --- a/detached-head/fix-detached-head +++ b/detached-head/fix-detached-head @@ -6,8 +6,13 @@ pwd declare -a branches branches=(`git branch --points-at=HEAD | tail -n +2`) + +if [ "${#branches[*]}" -eq 0 ]; then + branches=(`git config -f $toplevel/.gitmodules --get submodule.$name.branch`) +fi + if [ "${#branches[*]}" -eq 0 ]; then - branches=(`git branch --points-at=HEAD -r | sed 's!^ *origin/!!'`) + branches=(`git for-each-ref --format="%(refname:lstrip=3)" --points-at=HEAD refs/remotes | sort -u`) fi if [ "${#branches[*]}" -eq 0 ]; then