summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/git.py
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-08-15 21:44:01 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-08-19 11:35:52 +0100
commit3d451f3452643a6fcaa7ff9345a6f955392daec3 (patch)
treeb833abc48bb9b3f27c30a5f8b6440b244396ec69 /bitbake/lib/bb/fetch2/git.py
parent2f808c92cc8d09a42e66f522c6c3f798cabf52d3 (diff)
downloadpoky-3d451f3452643a6fcaa7ff9345a6f955392daec3.tar.gz
bitbake: fetch2/git: verify if local clone contains tag
In case a recipe specifies a git SRC_URI along with revision and tag, but only the revision is present in the local clone without the tag (because it was tagged after it was cloned), then unpacking fails with the following error: ... rev-list -n 1 1.0 failed with exit code 128, output:\nfatal: ambiguous argument \'1.0\': unknown revision or path not in the working tree This happens because the during the download step only the revision's presence is verified to decide if the repository needs to be updated. To avoid this, check also if the tag is present in the local repository, when the "tag" tag is specified. (Bitbake rev: 546b347b4d3d82c01ecc99f45296f66e44638adc) Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r--bitbake/lib/bb/fetch2/git.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index ecaf0a49af..52fffe21d7 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -323,6 +323,8 @@ class Git(FetchMethod):
323 return True 323 return True
324 if not self._contains_ref(ud, d, ud.name, ud.clonedir): 324 if not self._contains_ref(ud, d, ud.name, ud.clonedir):
325 return True 325 return True
326 if 'tag' in ud.parm and not self._contains_ref(ud, d, ud.name, ud.clonedir, tag=True):
327 return True
326 return False 328 return False
327 329
328 def lfs_need_update(self, ud, d): 330 def lfs_need_update(self, ud, d):
@@ -775,14 +777,16 @@ class Git(FetchMethod):
775 def supports_srcrev(self): 777 def supports_srcrev(self):
776 return True 778 return True
777 779
778 def _contains_ref(self, ud, d, name, wd): 780 def _contains_ref(self, ud, d, name, wd, tag=False):
779 cmd = "" 781 cmd = ""
782 git_ref_name = 'refs/tags/%s' % ud.parm['tag'] if tag else ud.revision
783
780 if ud.nobranch: 784 if ud.nobranch:
781 cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % ( 785 cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (
782 ud.basecmd, ud.revision) 786 ud.basecmd, git_ref_name)
783 else: 787 else:
784 cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % ( 788 cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
785 ud.basecmd, ud.revision, ud.branch) 789 ud.basecmd, git_ref_name, ud.branch)
786 try: 790 try:
787 output = runfetchcmd(cmd, d, quiet=True, workdir=wd) 791 output = runfetchcmd(cmd, d, quiet=True, workdir=wd)
788 except bb.fetch2.FetchError: 792 except bb.fetch2.FetchError: