When you clone with "--single-branch --branch foo" one of two things
will happen:
If foo is a branch upstream you will get a local branch foo and HEAD
will contain "ref: refs/heads/foo". Output from "git branch" will be:
* foo
If foo is a tag upstream, you won't get any local branch, and HEAD
will contain the SHA of the tag foo. Output from "git branch" will be:
* (no branch)
In the latter case, people tend to assume it is some kind of indication
progress was interrupted and an error happened.
While not strictly necessary, in static repos, we point master at the
tag that was fetched if no branches are present, to avoid confusion.
Signed-off-by: Paul Gortmaker <[email protected]>
---
bitbake/lib/bb/fetch2/git.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 7cba990c3be7..6cd5d09b2ded 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -417,6 +417,15 @@ class Git(FetchMethod):
if exc.errno != errno.ENOENT:
raise
+ # fixup "* (no branch)" from "--single-branch --branch <tag>"
+ if ud.static:
+ output = runfetchcmd("%s show-ref --heads | wc -l" % ud.basecmd,
d, workdir=ud.clonedir)
+ headless = output.split()[0] == "0"
+ if headless:
+ runfetchcmd("%s update-ref refs/heads/master HEAD" %
ud.basecmd, d, workdir=ud.clonedir)
+ with open(os.path.join(ud.clonedir, "HEAD"), "w") as f:
+ f.write('ref: refs/heads/master\n')
+
for name in ud.names:
if not self._contains_ref(ud, d, name, ud.clonedir):
raise bb.fetch2.FetchError("Unable to find revision %s in
branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9640):
https://lists.yoctoproject.org/g/linux-yocto/message/9640
Mute This Topic: https://lists.yoctoproject.org/mt/81808158/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-