Skip to contentSkip to conversation

doc: bitbake-user-manual-ref-variables: document BB_GIT_SHALLOW_EXTRA_REFS

PATCH New Martin Schwan 2 participants 3 messages Nov 5, 2025 – Nov 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 doc: bitbake-user-manual-ref-variables: document BB_GIT_SHALLOW_EXTRA_REFS

Describe BB_GIT_SHALLOW_EXTRA_REFS which allows keeping additional refs for shallow clones.

---
 .../bitbake-user-manual-ref-variables.rst       | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +17 -0
index 734c7858a..309477071 100644
@@ -399,6 +399,23 @@ overview of their function and contents.
 
       For example usage, see :term:`BB_GIT_SHALLOW`.
 
+   :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      With :term:`BB_GIT_SHALLOW` enabled, by default, all unused refs (branches
+      and tags) are removed from the repository, as shallow processing scales
+      with the number of refs it has to process.
+
+      :term:`BB_GIT_SHALLOW_EXTRA_REFS` allows to explicitly specify additional
+      refs to keep. This is particularly useful for recipes with custom checkout
+      processes, or whose Git-based versioning requires a tag be available (i.e.
+      for ``git describe --tags``). The :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      variable is a space-separated list of refs, fully specified, and supports
+      wildcards.
+
+      Example usage::
+
+         BB_GIT_SHALLOW_EXTRA_REFS = "refs/tags/v1.0"
+         BB_GIT_SHALLOW_EXTRA_REFS += "refs/heads/*"
+
    :term:`BB_GLOBAL_PYMODULES`
       Specifies the list of Python modules to place in the global namespace.
       It is intended that only the core layer should set this and it is meant
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 doc: bitbake-user-manual-ref-variables: document BB_GIT_SHALLOW_EXTRA_REFS

Describe BB_GIT_SHALLOW_EXTRA_REFS which allows keeping additional refs for shallow clones.

---
 .../bitbake-user-manual-ref-variables.rst       | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +17 -0
index 734c7858a..309477071 100644
@@ -399,6 +399,23 @@ overview of their function and contents.
 
       For example usage, see :term:`BB_GIT_SHALLOW`.
 
+   :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      With :term:`BB_GIT_SHALLOW` enabled, by default, all unused refs (branches
+      and tags) are removed from the repository, as shallow processing scales
+      with the number of refs it has to process.
+
+      :term:`BB_GIT_SHALLOW_EXTRA_REFS` allows to explicitly specify additional
+      refs to keep. This is particularly useful for recipes with custom checkout
+      processes, or whose Git-based versioning requires a tag be available (i.e.
+      for ``git describe --tags``). The :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      variable is a space-separated list of refs, fully specified, and supports
+      wildcards.
+
+      Example usage::
+
+         BB_GIT_SHALLOW_EXTRA_REFS = "refs/tags/v1.0"
+         BB_GIT_SHALLOW_EXTRA_REFS += "refs/heads/*"
+
    :term:`BB_GLOBAL_PYMODULES`
       Specifies the list of Python modules to place in the global namespace.
       It is intended that only the core layer should set this and it is meant
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#2 lore raw

Hi Martin,

Quoted 5 lines · Martin Schwan via lists.openembedded.org

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Describe BB_GIT_SHALLOW_EXTRA_REFS which allows keeping additional refs for shallow clones.

Available since sumo (bitbake 1.36.0), commit 1771934cd9f8 ("fetch/git: add support for keeping extra refs for shallow").

It'd be nice to provide this kind of info in the future, helps deciding if and for which branches to backport this.

Quoted 11 lines
---
  .../bitbake-user-manual-ref-variables.rst       | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +0 -0
index 734c7858a..309477071 100644
@@ -399,6 +399,23 @@ overview of their function and contents.
 

doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst overview of their function and contents. · line 409

Quoted 10 lines
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +8 -0
        For example usage, see :term:`BB_GIT_SHALLOW`.
 
+   :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      With :term:`BB_GIT_SHALLOW` enabled, by default, all unused refs (branches
+      and tags) are removed from the repository, as shallow processing scales
+      with the number of refs it has to process.
+
+      :term:`BB_GIT_SHALLOW_EXTRA_REFS` allows to explicitly specify additional
+      refs to keep. This is particularly useful for recipes with custom checkout
+      processes, or whose Git-based versioning requires a tag be available (i.e.

Gut feeling says it should be "with a custom checkout process". I'm not a native speaker so eh.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst overview of their function and contents. · line 418

Quoted 9 lines
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +9 -0
+      for ``git describe --tags``). The :term:`BB_GIT_SHALLOW_EXTRA_REFS`
+      variable is a space-separated list of refs, fully specified, and supports
+      wildcards.
+
+      Example usage::
+
+         BB_GIT_SHALLOW_EXTRA_REFS = "refs/tags/v1.0"
+         BB_GIT_SHALLOW_EXTRA_REFS += "refs/heads/*"
+

I've read the code and it seems that if one specifies ;tag=X in SRC_URI for a source fetched by the git fetcher, that will make it make it to the list of refs that are kept (though not via the variable!). Something similar is applicable to the gitannex fetcher with git-annex and synced/* refs. I'm wondering if this is something we should document or not? @Antonin?

Looks good to me in any case, so:

Thanks!
Quentin