]> code.ossystems Code Review - openembedded-core.git/commitdiff
kernel-yocto: use show-ref instead of branch -a
authorBruce Ashfield <bruce.ashfield@windriver.com>
Wed, 19 Mar 2014 01:38:33 +0000 (21:38 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 1 Sep 2014 13:34:27 +0000 (14:34 +0100)
It's better to check a branches existence via show-ref versus the end
user branch commands. So we make the switch.

Also as part of this change, we move the conversion of remote branches
to local branches above the meta branch checking. This is required to
ensure that the branch is local for the show-ref check.

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
meta/classes/kernel-yocto.bbclass

index 0ac1572471bc8d257554f30df22fde862dbb7633..9209f423cff12b4a5f276cde9cc0fb2951920417 100644 (file)
@@ -200,11 +200,20 @@ do_kernel_checkout() {
        fi
        # end debare
 
+       # convert any remote branches to local tracking ones
+       for i in `git branch -a --no-color | grep remotes | grep -v HEAD`; do
+               b=`echo $i | cut -d' ' -f2 | sed 's%remotes/origin/%%'`;
+               git show-ref --quiet --verify -- "refs/heads/$b"
+               if [ $? -ne 0 ]; then
+                       git branch $b $i > /dev/null
+               fi
+       done
+
                # 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 --no-color | grep -q ${KMETA}
-               if [ $? -ne 0 ]; then
+               git show-ref --quiet --verify -- "refs/heads/${KMETA}"
+               if [ $? -eq 1 ]; then
                        echo "ERROR. The branch '${KMETA}' is required and was not"
                        echo "found. Ensure that the SRC_URI points to a valid linux-yocto"
                        echo "kernel repository"
@@ -214,15 +223,6 @@ do_kernel_checkout() {
        
        machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}"
 
-       # convert any remote branches to local tracking ones
-       for i in `git branch -a --no-color | grep remotes | grep -v HEAD`; do
-               b=`echo $i | cut -d' ' -f2 | sed 's%remotes/origin/%%'`;
-               git show-ref --quiet --verify -- "refs/heads/$b"
-               if [ $? -ne 0 ]; then
-                       git branch $b $i > /dev/null
-               fi
-       done
-
        # Create a working tree copy of the kernel by checking out a branch
        git show-ref --quiet --verify -- "refs/heads/${machine_branch}"
        if [ $? -eq 0 ]; then