From: Oleg Broytman Date: Tue, 4 Aug 2020 15:20:27 +0000 (+0300) Subject: Feat(fix-detached-head): Get branch from superproject X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=0a8706b3269a0fbeadd07ad87bc31a73ac54c519;p=git-scripts.git Feat(fix-detached-head): Get branch from superproject Get the branch from the superproject's `.gitmodules`. --- diff --git a/detached-head/fix-detached-head b/detached-head/fix-detached-head index 7be050a..bb75941 100755 --- a/detached-head/fix-detached-head +++ b/detached-head/fix-detached-head @@ -6,6 +6,11 @@ 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/!!'`) fi