]> git.phdru.name Git - git-scripts.git/commitdiff
Feat(fix-detached-head): Get branch from superproject
authorOleg Broytman <phd@phdru.name>
Tue, 4 Aug 2020 15:20:27 +0000 (18:20 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 4 Aug 2020 15:20:27 +0000 (18:20 +0300)
Get the branch from the superproject's `.gitmodules`.

detached-head/fix-detached-head

index 7be050aad8cf177ab93848786c112f2571220282..bb7594176cb64642ed32c861b8a3ac94afae149d 100755 (executable)
@@ -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