Patchwork [v2] kernel-yocto: Disable ANSI escape codes from git branch

login
register
mail settings
Submitter Matt Fleming
Date March 6, 2014, 11:04 a.m.
Message ID <1394103874-32687-1-git-send-email-matt@console-pimps.org>
Download mbox | patch
Permalink /patch/68103/
State New
Headers show

Comments

Matt Fleming - March 6, 2014, 11:04 a.m.
From: Matt Fleming <matt.fleming@intel.com>

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

Use the --no-color option to ensure all branch names are plain text.

Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2: Make the minimum change necessary to disable the escape codes per
    Bruce's suggestion.

 meta/classes/kernel-yocto.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Bruce Ashfield - March 6, 2014, 2:09 p.m.
On Thu, Mar 6, 2014 at 6:04 AM, Matt Fleming <matt@console-pimps.org> wrote:
> From: Matt Fleming <matt.fleming@intel.com>
>
> '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.
>
> Use the --no-color option to ensure all branch names are plain text.

Thanks for the low footprint version.

Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com>

>
> Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>
> v2: Make the minimum change necessary to disable the escape codes per
>     Bruce's suggestion.
>
>  meta/classes/kernel-yocto.bbclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
> index fb8e04e..7913dd8 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 branch -a --no-color | 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,7 +214,7 @@ do_kernel_checkout() {
>         fi
>
>         # convert any remote branches to local tracking ones
> -       for i in `git branch -a | grep remotes | grep -v HEAD`; do
> +       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
> --
> 1.8.5.3
>

Patch

diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index fb8e04e..7913dd8 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 branch -a --no-color | 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,7 +214,7 @@  do_kernel_checkout() {
 	fi
 
 	# convert any remote branches to local tracking ones
-	for i in `git branch -a | grep remotes | grep -v HEAD`; do
+	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