[meta-oe,warrior,1/2] gitpkgv.bbclass: Use --git-dir option

Submitted by Niko Mauno on Nov. 23, 2019, 1:46 p.m. | Patch ID: 167317

Details

Message ID 20191123134631.81271-1-niko.mauno@iki.fi
State Under Review
Delegated to: Armin Kuster
Headers show

Commit Message

Niko Mauno Nov. 23, 2019, 1:46 p.m.
From: "niko.mauno@vaisala.com" <niko.mauno@vaisala.com>

Avoid redundant shell working directory change by resorting to
'--git-dir' option for git command instead.

Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta-oe/classes/gitpkgv.bbclass | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
index 2d9680a35..22609f584 100644
--- a/meta-oe/classes/gitpkgv.bbclass
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -87,10 +87,8 @@  def get_git_pkgv(d, use_tags):
 
                 if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
                     commits = bb.fetch2.runfetchcmd(
-                        "cd %(repodir)s && "
-                        "git rev-list %(rev)s -- 2> /dev/null "
-                        "| wc -l" % vars,
-                        d, quiet=True).strip().lstrip('0')
+                        "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
+                        % vars, d, quiet=True).strip().lstrip('0')
 
                     if commits != "":
                         oe.path.remove(rev_file, recurse=False)
@@ -105,9 +103,8 @@  def get_git_pkgv(d, use_tags):
                 if use_tags:
                     try:
                         output = bb.fetch2.runfetchcmd(
-                            "cd %(repodir)s && "
-                            "git describe %(rev)s 2>/dev/null" % vars,
-                            d, quiet=True).strip()
+                            "git --git-dir=%(repodir)s describe %(rev)s 2>/dev/null"
+                            % vars, d, quiet=True).strip()
                         ver = gitpkgv_drop_tag_prefix(output)
                     except Exception:
                         ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])

Comments

Armin Kuster Nov. 24, 2019, 4:46 p.m.
wrong ml

On 11/23/19 5:46 AM, Niko Mauno wrote:
> From: "niko.mauno@vaisala.com" <niko.mauno@vaisala.com>
>
> Avoid redundant shell working directory change by resorting to
> '--git-dir' option for git command instead.
>
> Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta-oe/classes/gitpkgv.bbclass | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
> index 2d9680a35..22609f584 100644
> --- a/meta-oe/classes/gitpkgv.bbclass
> +++ b/meta-oe/classes/gitpkgv.bbclass
> @@ -87,10 +87,8 @@ def get_git_pkgv(d, use_tags):
>  
>                  if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
>                      commits = bb.fetch2.runfetchcmd(
> -                        "cd %(repodir)s && "
> -                        "git rev-list %(rev)s -- 2> /dev/null "
> -                        "| wc -l" % vars,
> -                        d, quiet=True).strip().lstrip('0')
> +                        "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
> +                        % vars, d, quiet=True).strip().lstrip('0')
>  
>                      if commits != "":
>                          oe.path.remove(rev_file, recurse=False)
> @@ -105,9 +103,8 @@ def get_git_pkgv(d, use_tags):
>                  if use_tags:
>                      try:
>                          output = bb.fetch2.runfetchcmd(
> -                            "cd %(repodir)s && "
> -                            "git describe %(rev)s 2>/dev/null" % vars,
> -                            d, quiet=True).strip()
> +                            "git --git-dir=%(repodir)s describe %(rev)s 2>/dev/null"
> +                            % vars, d, quiet=True).strip()
>                          ver = gitpkgv_drop_tag_prefix(output)
>                      except Exception:
>                          ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])
Peter Kjellerstedt Nov. 25, 2019, 1:59 p.m.
Uhm, what do you mean with "wrong ml"? Given that the 
gitpkgpv.bbclass is in meta-oe, this should be the correct 
mailing list for at patch to it...

//Peter

> -----Original Message-----
> From: openembedded-devel-bounces@lists.openembedded.org <openembedded-
> devel-bounces@lists.openembedded.org> On Behalf Of akuster808
> Sent: den 24 november 2019 17:46
> To: Niko Mauno <niko.mauno@iki.fi>; openembedded-
> devel@lists.openembedded.org
> Subject: Re: [oe] [meta-oe][warrior][PATCH 1/2] gitpkgv.bbclass: Use --
> git-dir option
> 
> wrong ml
> 
> On 11/23/19 5:46 AM, Niko Mauno wrote:
> > From: "niko.mauno@vaisala.com" <niko.mauno@vaisala.com>
> >
> > Avoid redundant shell working directory change by resorting to
> > '--git-dir' option for git command instead.
> >
> > Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  meta-oe/classes/gitpkgv.bbclass | 11 ++++-------
> >  1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-
> oe/classes/gitpkgv.bbclass
> > index 2d9680a35..22609f584 100644
> > --- a/meta-oe/classes/gitpkgv.bbclass
> > +++ b/meta-oe/classes/gitpkgv.bbclass
> > @@ -87,10 +87,8 @@ def get_git_pkgv(d, use_tags):
> >
> >                  if not os.path.exists(rev_file) or
> os.path.getsize(rev_file)==0:
> >                      commits = bb.fetch2.runfetchcmd(
> > -                        "cd %(repodir)s && "
> > -                        "git rev-list %(rev)s -- 2> /dev/null "
> > -                        "| wc -l" % vars,
> > -                        d, quiet=True).strip().lstrip('0')
> > +                        "git --git-dir=%(repodir)s rev-list %(rev)s --
> 2>/dev/null | wc -l"
> > +                        % vars, d, quiet=True).strip().lstrip('0')
> >
> >                      if commits != "":
> >                          oe.path.remove(rev_file, recurse=False)
> > @@ -105,9 +103,8 @@ def get_git_pkgv(d, use_tags):
> >                  if use_tags:
> >                      try:
> >                          output = bb.fetch2.runfetchcmd(
> > -                            "cd %(repodir)s && "
> > -                            "git describe %(rev)s 2>/dev/null" % vars,
> > -                            d, quiet=True).strip()
> > +                            "git --git-dir=%(repodir)s describe %(rev)s
> 2>/dev/null"
> > +                            % vars, d, quiet=True).strip()
> >                          ver = gitpkgv_drop_tag_prefix(output)
> >                      except Exception:
> >                          ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])
> 
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel