]> code.ossystems Code Review - openembedded-core.git/commitdiff
kernel-yocto: Simplify no git repo case in do_kernel_checkout
authorPaul Barker <paul@pbarker.dev>
Mon, 2 Aug 2021 10:44:30 +0000 (11:44 +0100)
committerAnuj Mittal <anuj.mittal@intel.com>
Mon, 6 Sep 2021 03:08:20 +0000 (11:08 +0800)
If the kernel sources are not fetched via git, a local git repository is
created in do_kernel_checkout. In this case we know that there will be
no remote branches and we will already be on the correct branch (since
only one branch will exist). So we can simplify things by skipping these
steps.

This also removes the assumption that the default git branch name will
be "master". Prior to this change, the final git checkout command in
do_kernel_checkout could fail if a local git repo was created and the
user had changed init.defaultBranch in their gitconfig.

Signed-off-by: Paul Barker <paul@pbarker.dev>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit af2a9c92d4498492ca23388c7b4bbed48abdc4d7)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
meta/classes/kernel-yocto.bbclass

index d38b60f519b339789143f3b46d918323a5a849b1..8878573f6fa5d1324ce0e7933d82c16e72118a4f 100644 (file)
@@ -341,6 +341,21 @@ do_kernel_checkout() {
                        fi
                fi
                cd ${S}
+
+               # 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
+               machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}"
+
+               # checkout and clobber any unimportant files
+               git checkout -f ${machine_branch}
        else
                # case: we have no git repository at all. 
                # To support low bandwidth options for building the kernel, we'll just 
@@ -362,21 +377,6 @@ do_kernel_checkout() {
                git commit -q -m "baseline commit: creating repo for ${PN}-${PV}"
                git clean -d -f
        fi
-
-       # 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
-       machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}"
-
-       # checkout and clobber any unimportant files
-       git checkout -f ${machine_branch}
 }
 do_kernel_checkout[dirs] = "${S} ${WORKDIR}"