<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>16194</bug_id>
          
          <creation_ts>2026-03-10 20:34:12 +0000</creation_ts>
          <short_desc>Git fetcher doesn&apos;t redownload/update shallow tarball when lfs=1</short_desc>
          <delta_ts>2026-10-01 15:48:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michal Sieron">michalwsieron</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>104574</commentid>
    <comment_count>0</comment_count>
    <who name="Michal Sieron">michalwsieron</who>
    <bug_when>2026-03-10 20:34:12 +0000</bug_when>
    <thetext>Scenario I am describing is that multiple recipes fetch the same repo, but one of them is not requesting git-lfs data (lfs=0) and another one does (lfs=1).

If we have BB_GIT_SHALLOW enabled for those recipes, there is a risk that if do_fetch for recipe *not* requesting git-lfs data (let&apos;s call it foo.bb) runs before the other one - bar.bb, do_unpack for bar.bb will fail as it won&apos;t be able to retrieve git-lfs data from remote.

Here is a &quot;synthetic test&quot; for that scenario:
```
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 74eb73472..028639ba1 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2600,6 +2600,28 @@ class GitLfsTest(FetcherTest):
             shutil.rmtree(self.gitdir, ignore_errors=True)
             fetcher.unpack(self.d.getVar(&apos;WORKDIR&apos;))
 
+    @skipIfNoGitLFS()
+    @skipIfNoNetwork()
+    def test_shallow_tarball_with_lfs(self):
+        uri = &quot;git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master&quot;
+
+        # Use shallow tarballs
+        self.d.setVar(&apos;BB_GIT_SHALLOW&apos;, &apos;1&apos;)
+        self.d.setVar(&apos;BB_GENERATE_SHALLOW_TARBALLS&apos;, &apos;1&apos;)
+
+        # Download without git-lfs
+        self.d.setVar(&apos;SRC_URI&apos;, uri + &quot;;lfs=0&quot;)
+        fetcher, ud = self.fetch()
+
+        # Redownload with git-lfs
+        self.d.setVar(&apos;SRC_URI&apos;, uri + &quot;;lfs=1&quot;)
+        fetcher, ud = self.fetch()
+
+        # Attempt unpack without network
+        bb.utils.disable_network()
+        fetcher.unpack(self.d.getVar(&apos;WORKDIR&apos;))
+
+
 class GitURLWithSpacesTest(FetcherTest):
     test_git_urls = {
         &quot;git://tfs-example.org:22/tfs/example%20path/example.git;branch=master&quot; : {
```

You should run above test with `bin/bitbake-selftest bb.tests.fetch.GitLfsTest -k test_shallow_tarball_with_lfs`.

*Expected behavior*: Test passes, because when bitbake is supposed to download a shallow tarball with git-lfs blobs, it will check whether the git-lfs blobs are actually available and download them if needed.

*Actual behavior*: Test fails at the unpack step with git-lfs unable to fetch the blob.

I fear that to properly support such case without doing tarball content checks all the time, we would have to split the git-lfs blobs into a separate tarball. Then if a recipe sets lfs=1, both shallow tarball and lfs tarball would be unpacked. It could also be reused for full mirror tarballs, because from what I checked it can also affect them.

---

Side topic, I had to use `bb.utils.disable_network()` as I found no other way to disable network access for the unpack functionality in the tests. However it is not a viable way to actually do this as it affects the entire testing process and subsequent network tests will fail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104595</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-03-12 14:40:09 +0000</bug_when>
    <thetext>Richard to comment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104596</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2026-03-12 14:40:38 +0000</bug_when>
    <thetext>At a quick guess, I suspect that the tarball names need to reflect whether lfs was enabled or not. If we do that there would be different tarball archives for both and then things should work properly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>