Skip to contentSkip to conversation

fetch/git: Ensure tags work with shallow clones

PATCH In review Richard Purdie 2 participants 3 messages Mar 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch/git: Ensure tags work with shallow clones

If we want to validate a tag when using shallow clones, we need to ensure the tag is imported to the clone. Adding to extra_refs allows this to happen ensuring tag validation in shallow clones works.

---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/git.py +2 -0
index 53fdc4c3df..7fda9d2753 100644
@@ -674,6 +674,8 @@ class Git(FetchMethod):
         for line in all_refs_remote:
             all_refs.append(line.split()[-1])
         extra_refs = []
+        if 'tag' in ud.parm:
+            extra_refs.append(ud.parm['tag'])
         for r in ud.shallow_extra_refs:
             if not ud.bareclone:
                 r = r.replace('refs/heads/', 'refs/remotes/origin/')
#1 lore raw

Hello Richard,

Thanks for this patch,
Could we also add the tag to git shallow tarball filename? Or make some other filename change?

I don't want to re-write all existing shallow tarballs in our mirror, which would be now failing to verify the tag.

Thanks,
Peter

Quoted 30 lines

-----Original Message-----
From: [email protected] <bitbake- [email protected]> On Behalf Of Richard Purdie via lists.openembedded.org
Sent: Tuesday, March 18, 2025 13:16
To: [email protected]
Subject: [bitbake-devel] [PATCH] fetch/git: Ensure tags work with shallow clones

If we want to validate a tag when using shallow clones, we need to ensure the tag is imported to the clone. Adding to extra_refs allows this to happen ensuring tag validation in shallow clones works.

---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/git.py +2 -0
index 53fdc4c3df..7fda9d2753 100644
@@ -674,6 +674,8 @@ class Git(FetchMethod):
         for line in all_refs_remote:
             all_refs.append(line.split()[-1])
         extra_refs = []
+        if 'tag' in ud.parm:
+            extra_refs.append(ud.parm['tag'])
         for r in ud.shallow_extra_refs:
             if not ud.bareclone:
                 r = r.replace('refs/heads/', 'refs/remotes/origin/')
#2 lore raw

Thinking about it again, I think it's not necessary to change filename. Tags will anyway be needed only on upgrades, so new tarball will be generated.

Sorry for unnecessary spam.

Peter

Quoted 49 lines

-----Original Message-----
From: Marko, Peter (FT D EU SK BFS1)
Sent: Tuesday, March 18, 2025 13:23
To: [email protected]; [email protected]
Subject: RE: [bitbake-devel] [PATCH] fetch/git: Ensure tags work with shallow clones

Hello Richard,

Thanks for this patch,
Could we also add the tag to git shallow tarball filename? Or make some other filename change?

I don't want to re-write all existing shallow tarballs in our mirror, which would be now failing to verify the tag.

Thanks,
Peter

Quoted 30 lines

-----Original Message-----
From: [email protected] <bitbake- [email protected]> On Behalf Of Richard Purdie via lists.openembedded.org
Sent: Tuesday, March 18, 2025 13:16
To: [email protected]
Subject: [bitbake-devel] [PATCH] fetch/git: Ensure tags work with shallow clones

If we want to validate a tag when using shallow clones, we need to ensure the tag is imported to the clone. Adding to extra_refs allows this to happen ensuring tag validation in shallow clones works.

---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/git.py +2 -0
index 53fdc4c3df..7fda9d2753 100644
@@ -674,6 +674,8 @@ class Git(FetchMethod):
         for line in all_refs_remote:
             all_refs.append(line.split()[-1])
         extra_refs = []
+        if 'tag' in ud.parm:
+            extra_refs.append(ud.parm['tag'])
         for r in ud.shallow_extra_refs:
             if not ud.bareclone:
                 r = r.replace('refs/heads/', 'refs/remotes/origin/')