Skip to contentSkip to conversation

Fixes for the Git fetcher

PATCH New Peter Kjellerstedt 1 participant 2 messages May 23, 2016

lore
Share & tools
lore
#0 lore raw

cover Fixes for the Git fetcher

This fixes a problem with the Git fetcher where it could assign the wrong SHA-1 to a Git reference. The problem was that the matching done in _latest_revision() wasn't exact, which means that, e.g., SRCREV = "R${PV}" where PV = "1.0" would match a tag called R1.0.0, rather than fail as it should since the tag R1.0 does not exist.

//Peter

The following changes since commit c7e614c438706fb3ed7520b4990ebb3973366942:

useradd: Fix infinite build loop (2016-05-23 10:33:45 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib pkj/exact_git_refs
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/exact_git_refs

Peter Kjellerstedt (1):
fetch2/git.py: References must match exactly

 bitbake/lib/bb/fetch2/git.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 fetch2/git.py: References must match exactly

Previously the code used to match a reference to its SHA-1 in _latest_revision() used the Python "in" operator, which made it match if the reference matched the beginning of an existing tag or branch. This test, however, must be exact. I.e., either the reference matches a tag or branch exactly, or it does not match at all.

---
 bitbake/lib/bb/fetch2/git.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
bitbake/lib/bb/fetch2/git.py +4 -3
index 526668b..59827e3 100644
@@ -350,9 +350,10 @@ class Git(FetchMethod):
             head = "refs/heads/%s" % ud.unresolvedrev[name]
             tag = "refs/tags/%s" % ud.unresolvedrev[name]
         for s in [head, tag + "^{}", tag]:
-            for l in output.split('\n'):
-                if s in l:
-                    return l.split()[0]
+            for l in output.strip().split('\n'):
+                sha1, ref = l.split()
+                if s == ref:
+                    return sha1
         raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output for %s" % \
             (ud.unresolvedrev[name], ud.host+ud.path))
 
Signature · 1 line
2.1.0