diff mbox series

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

Message ID 20260205225528.92769-7-rs@ti.com
State New
Headers show
Series oe-layertool-setup: general clean up and bugfix | expand

Commit Message

Randolph Sapp Feb. 5, 2026, 10:55 p.m. UTC
From: Randolph Sapp <rs@ti.com>

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 <rs@ti.com>
---
 oe-layertool-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

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