]> git.phdru.name Git - git-scripts.git/commitdiff
Feat(fix-detached-head): Replace `branch -r` by `for-each-ref`
authorOleg Broytman <phd@phdru.name>
Tue, 4 Aug 2020 15:22:40 +0000 (18:22 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 4 Aug 2020 15:30:18 +0000 (18:30 +0300)
Use `git for-each-ref` instead of `git branch -r | sed`.

detached-head/fix-detached-head

index bb7594176cb64642ed32c861b8a3ac94afae149d..44b98443da82158f004c3a34239bc22b0d2b2d21 100755 (executable)
@@ -12,7 +12,7 @@ if [ "${#branches[*]}" -eq 0 ]; then
 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