From: Matt Fleming <[email protected]>

'git branch' may use ANSI escape codes in its output (to provide colour)
which doesn't play well with commands expecting pure plain text, e.g.

    fatal: '^[[31mmaster^[[m' is not a valid branch name.

Furthermore, the output of 'git branch' is subject to change and trying
to parse it could potentially lead to breakage in the future.

Signed-off-by: Matt Fleming <[email protected]>
---
 meta/classes/kernel-yocto.bbclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/classes/kernel-yocto.bbclass 
b/meta/classes/kernel-yocto.bbclass
index fb8e04e..1115056 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -196,7 +196,7 @@ do_kernel_checkout() {
                # If KMETA is defined, the branch must exist, but a machine 
branch
        # can be missing since it may be created later by the tools.
        if [ -n "${KMETA}" ]; then
-               git branch -a | grep -q ${KMETA}
+               git ls-remote --heads 2>/dev/null | awk '{print $NF}' | grep -q 
${KMETA}
                if [ $? -ne 0 ]; then
                        echo "ERROR. The branch '${KMETA}' is required and was 
not"
                        echo "found. Ensure that the SRC_URI points to a valid 
linux-yocto"
@@ -214,11 +214,11 @@ do_kernel_checkout() {
        fi
 
        # convert any remote branches to local tracking ones
-       for i in `git branch -a | grep remotes | grep -v HEAD`; do
-               b=`echo $i | cut -d' ' -f2 | sed 's%remotes/origin/%%'`;
-               git show-ref --quiet --verify -- "refs/heads/$b"
+       for i in `git ls-remote --heads 2>/dev/null | awk '{print $NF}'`; do
+               b=`echo $i | sed 's%refs/heads/%%'`;
+               git show-ref --quiet --verify -- "$i"
                if [ $? -ne 0 ]; then
-                       git branch $b $i > /dev/null
+                       git branch $b remotes/origin/$b > /dev/null
                fi
        done
 
-- 
1.8.5.3

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to