From: Oleg Broytman Date: Tue, 4 Aug 2020 15:22:40 +0000 (+0300) Subject: Feat(fix-detached-head): Replace `branch -r` by `for-each-ref` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=b90789d369c5500fa85a0954869626e8aa3566ce;p=git-scripts.git Feat(fix-detached-head): Replace `branch -r` by `for-each-ref` Use `git for-each-ref` instead of `git branch -r | sed`. --- diff --git a/detached-head/fix-detached-head b/detached-head/fix-detached-head index bb75941..44b9844 100755 --- a/detached-head/fix-detached-head +++ b/detached-head/fix-detached-head @@ -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