From: Ulf Magnusson <ulfalizer@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: dev@codyops.com
Subject: [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer
Date: Mon, 12 Sep 2016 22:11:04 +0200 [thread overview]
Message-ID: <1473711064-9680-1-git-send-email-ulfalizer@gmail.com> (raw)
Given two names "foo" and "foobar" and SRCREV_FORMAT = "foo_foobar",
"foo" might currently get substituted twice. Work around the issue by
sorting the list of names by length and substituting longer names first.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
---
bitbake/lib/bb/fetch2/__init__.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 11c75cc..4ca024e 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -764,7 +764,10 @@ def get_srcrev(d, method_name='sortable_revision'):
seenautoinc = False
for scm in scms:
ud = urldata[scm]
- for name in ud.names:
+ # Sort the list of names and replace the longest names first. Given two
+ # names "foo" and "foobar", this prevents "foo" being substituted twice
+ # in "foo_foobar" (and "foobar" from not being substituted at all).
+ for name in sorted(ud.names, key=len, reverse=True):
autoinc, rev = getattr(ud.method, method_name)(ud, d, name)
seenautoinc = seenautoinc or autoinc
if len(rev) > 10:
--
2.5.0
next reply other threads:[~2016-09-12 20:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 20:11 Ulf Magnusson [this message]
2016-09-12 20:18 ` [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer Ulf Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473711064-9680-1-git-send-email-ulfalizer@gmail.com \
--to=ulfalizer@gmail.com \
--cc=dev@codyops.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox