[meta-arago][oe-layersetup][PATCH 5/5] oe-layertool-setup: use git to trim ref parts

<[email protected]>
Newsgroups org.yoctoproject.lists.meta-arago
Message-ID <[email protected]>
From: Randolph Sapp <[email protected]>

Use git formatting to strip ref parts more consistently. Tighten grep
patterns to make sure we don't get any partial matches.

Signed-off-by: Randolph Sapp <[email protected]>
---
 oe-layertool-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh
index db870af..dff2565 100755
--- a/oe-layertool-setup.sh
+++ b/oe-layertool-setup.sh
@@ -416,10 +416,10 @@ get_repo_branch() {
 
         # Get a unique list of branches for the user to chose from
         # Also delete the origin/HEAD line that the -r option returns
-        t_branches=$(git branch -r | sed '/origin\/HEAD/d')
+        t_branches=$(git branch -r --format='%(refname:strip=3)' | grep -v '^HEAD$')
         for b in $t_branches
         do
-            branches="${branches}$(printf '%s\n' "$b" | sed 's:.*origin/::g')\n"
+            branches="${branches}$(printf '%s\n' "$b")\n"
         done
         branches=$(printf '%s\n' "$branches" | sort | uniq)
 
@@ -460,7 +460,7 @@ checkout_branch() {
     # Check if a local branch already exists to track the remote branch.
     # If not then create a tracking branch and checkout the branch
     # else just checkout the existing branch
-    if git branch | grep -q "$branch"
+    if git branch --format='%(refname:short)' | grep -q "^$branch\$"
     then
         git checkout "$branch"
     else
-- 
2.52.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.