If a clone in the download directory is not static, and was created with
single-branch to avoid additonal unwanted content, then the fetcher will
come along and spoil that effort by unconditonally getting refs/* from
the server and downloading everything available at the server.

To that end, allow a companion variable that can optionally be used to
limit the fetch to a subset of references that are in line with the
desired content for the recipe in question, and so that large unwanted
downloads aren't inadvertently triggered during an update.

If not specified, the existing "fetch everything" behaviour remains.

Signed-off-by: Paul Gortmaker <paul.gortma...@windriver.com>
---
 bitbake/lib/bb/fetch2/git.py           | 3 ++-
 documentation/ref-manual/variables.rst | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 22281e2cfb98..b54ec76d7174 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -362,7 +362,8 @@ class Git(FetchMethod):
               runfetchcmd("%s remote rm origin" % ud.basecmd, d, 
workdir=ud.clonedir)
 
             runfetchcmd("%s remote add --mirror=fetch origin %s" % 
(ud.basecmd, shlex.quote(repourl)), d, workdir=ud.clonedir)
-            fetch_cmd = "LANG=C %s fetch -f --progress %s refs/*:refs/*" % 
(ud.basecmd, shlex.quote(repourl))
+            fetchrefs = d.getVar('GITFETCHREFS_' + ud.names[0]) or 
d.getVar('GITFETCHREFS') or "refs/*:refs/*"
+            fetch_cmd = "LANG=C %s fetch -f --progress %s %s" % (ud.basecmd, 
shlex.quote(repourl), fetchrefs)
             if ud.proto.lower() != 'file':
                 bb.fetch2.check_network_access(d, fetch_cmd, ud.url)
             progresshandler = GitProgressHandler(d)
diff --git a/documentation/ref-manual/variables.rst 
b/documentation/ref-manual/variables.rst
index cd2b77604e87..55028987c08a 100644
--- a/documentation/ref-manual/variables.rst
+++ b/documentation/ref-manual/variables.rst
@@ -2661,6 +2661,14 @@ system and gives an overview of their function and 
contents.
       The directory in which a local copy of a Git repository is stored
       when it is cloned.
 
+   :term:`GITFETCHREFS`
+      The refs requested during a "git fetch" when updating a repo from
+      an external server into the local download area.  The default is
+      "refs/*:refs/*".  Used in conjunction with GITCLONEARGS to limit what
+      is cloned/fetched from a repo otherwise dense with branches.  Note
+      that an URL specific GITFETCHREFS_<name> will take precedence over
+      a recipe wide GITFETCHREFS setting, if both are present.
+
    :term:`GLIBC_GENERATE_LOCALES`
       Specifies the list of GLIBC locales to generate should you not wish
       to generate all LIBC locals, which can be time consuming.
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9637): 
https://lists.yoctoproject.org/g/linux-yocto/message/9637
Mute This Topic: https://lists.yoctoproject.org/mt/81808153/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to