All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel-yocto: Simplify no git repo case in do_kernel_checkout
@ 2021-08-02 10:44 Paul Barker
  2021-08-02 19:33 ` Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Barker @ 2021-08-02 10:44 UTC (permalink / raw
  To: openembedded-core, Bruce Ashfield; +Cc: Paul Barker

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>
---
 meta/classes/kernel-yocto.bbclass | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 0df61cdef0..18b77e2b9f 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -358,6 +358,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 
@@ -379,21 +394,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}"
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel-yocto: Simplify no git repo case in do_kernel_checkout
  2021-08-02 10:44 [PATCH] kernel-yocto: Simplify no git repo case in do_kernel_checkout Paul Barker
@ 2021-08-02 19:33 ` Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2021-08-02 19:33 UTC (permalink / raw
  To: Paul Barker; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 3412 bytes --]

On Mon, Aug 2, 2021 at 6:44 AM Paul Barker <paul@pbarker.dev> wrote:

> 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.
>

Looks ok to me. No concerns jumped out.

Richard: I can take this into my queue, or you can grab it directly, either
works for me.

Bruce



>
> Signed-off-by: Paul Barker <paul@pbarker.dev>
> ---
>  meta/classes/kernel-yocto.bbclass | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/meta/classes/kernel-yocto.bbclass
> b/meta/classes/kernel-yocto.bbclass
> index 0df61cdef0..18b77e2b9f 100644
> --- a/meta/classes/kernel-yocto.bbclass
> +++ b/meta/classes/kernel-yocto.bbclass
> @@ -358,6 +358,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
> @@ -379,21 +394,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}"
>
> --
> 2.31.1
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

[-- Attachment #2: Type: text/html, Size: 4885 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-02 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-02 10:44 [PATCH] kernel-yocto: Simplify no git repo case in do_kernel_checkout Paul Barker
2021-08-02 19:33 ` Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.