All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <bluelightning@bluelightning.org>
To: Maia Xiao <t-maiaxiao@linux.microsoft.com>,
	bitbake-devel@lists.openembedded.org
Cc: Paul Eggleton <Paul.Eggleton@microsoft.com>,
	Richard Purdie <richard.purdie@linuxfoundation.org>,
	Ross Burton <ross.burton@arm.com>
Subject: Re: [bitbake-devel] [PATCH] fetch2/git: Check srcrev exists in checkstatus()
Date: Wed, 06 Jul 2022 10:02:07 +1200	[thread overview]
Message-ID: <4791753.GXAFRqVoOG@linc> (raw)
In-Reply-To: <1ce72dadf44e9ee42094cc3d8afd906373fdc043.camel@linuxfoundation.org>

On Wednesday, 6 July 2022 09:27:38 NZST Richard Purdie wrote:
> On Tue, 2022-07-05 at 17:46 +0000, Maia Xiao wrote:
> > Currently we only check that we can list the remote, but do not validate
> > if the srcrev actually exists. Now we ensure that the rev exists by
> > attempting to shallow clone it from the remote.
> > 
> > Fixes [YOCTO #11199].
> > 
> > Signed-off-by: Maia Xiao <t-maiaxiao@linux.microsoft.com>
> > ---
> > 
> >  lib/bb/fetch2/git.py  | 28 +++++++++++++++++++++++-----
> >  lib/bb/tests/fetch.py | 34 ++++++++++++++++++++++++++++++++++
> >  2 files changed, 57 insertions(+), 5 deletions(-)
> > 
> > diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> > index 07b3d9a7..99780de8 100644
> > --- a/lib/bb/fetch2/git.py
> > +++ b/lib/bb/fetch2/git.py
> > 
> > @@ -832,8 +832,26 @@ class Git(FetchMethod):
> >              return True, str(rev)
> >      
> >      def checkstatus(self, fetch, ud, d):
> > -        try:
> > -            self._lsremote(ud, d, "")
> > -            return True
> > -        except bb.fetch2.FetchError:
> > -            return False
> > +        repourl = self._get_repo_url(ud)
> > +        for name in ud.names:
> > +            tmpdir = tempfile.mkdtemp()
> > +            revision = ud.revisions[name]
> > +
> > +            try:
> > +                # Initialise an empty git repo for shallow fetching
> > +                runfetchcmd("%s init" % ud.basecmd, d, workdir=tmpdir)
> > +                runfetchcmd("%s remote add origin %s" %
> > +                            (ud.basecmd, shlex.quote(repourl)),
> > +                            d,
> > +                            workdir=tmpdir)
> > +
> > +                # Try to fetch only the specified srcrev
> > +                runfetchcmd("%s fetch -f --progress --depth 1 origin %s"
> > %
> > +                            (ud.basecmd, revision),
> > +                            d,
> > +                            workdir=tmpdir)
> > +            except bb.fetch2.FetchError:
> > +                return False
> > +            finally:
> > +                bb.utils.remove(tmpdir, recurse=True)
> > +        return True
> 
> This makes the git backend do something quite different from the
> design. For instance the wget backend will only check that an http file
> exists, it won't attempt to actually download it.
> 
> I'm therefore not convinced this is the right thing to make
> checkstatus() do...

I'm not sure there is a better way to do it currently - git ls-remote lists 
only certain refs (corresponding to tags and branches), so checking the output 
of that would be a potential shortcut and would work in a lot of cases, but 
this would still have to be a fallback. There is support for fetching a 
particular revision in recent versions of git (2.5+), but apparently the 
server has to support and enable it [1] and that would still count as 
downloading.

I guess it just depends on how much we need/want checkstatus to check the 
revision. Adding Ross as the original reporter of the bug.

Cheers
Paul

[1] https://stackoverflow.com/questions/14872486/retrieve-specific-commit-from-a-remote-git-repository/30701724#30701724





  reply	other threads:[~2022-07-05 22:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 17:46 [PATCH] fetch2/git: Check srcrev exists in checkstatus() Maia Xiao
2022-07-05 21:27 ` [bitbake-devel] " Richard Purdie
2022-07-05 22:02   ` Paul Eggleton [this message]
2022-07-06 15:12 ` Bruce Ashfield
2022-07-06 15:13   ` Bruce Ashfield
2022-07-06 16:19     ` Richard Purdie
2022-07-06 20:14       ` Maia Xiao
2022-07-07 16:55         ` Bruce Ashfield
2022-07-07 20:50           ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4791753.GXAFRqVoOG@linc \
    --to=bluelightning@bluelightning.org \
    --cc=Paul.Eggleton@microsoft.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=ross.burton@arm.com \
    --cc=t-maiaxiao@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.