Skip to contentSkip to conversation

fetch2/git: allow using 'HEAD' as a branch name

PATCH In review Markus Lehtonen 2 participants 3 messages May 18, 2016 – Jul 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/git: allow using 'HEAD' as a branch name

This change makes it possible to e.g. build a currently checked out revision of a local Git repository and use AUTOREV. It will be possible to build HEAD of remote repositories, too, of course, but this is probably not that practical.

In order to use this one must also use the nobranch parameter, i.e. have 'branch=HEAD;nobranch=1' in the SRC_URI, because 'HEAD' is really not a Git branch as such. The wording in "branch=HEAD;nobranch=1" is probably a bit counter-intuitive and illogical but this seems to be the only easy way to make this work without complicating the fetcher even further. Another solution would be e.g. to introduce an alternative 'ref' parameter which could be used in place of 'branch' to give any ref. The effect would basically be the same (with better wording) with yet a bit more complex fetcher code.

[YOCTO #9351]

---
 lib/bb/fetch2/git.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/bb/fetch2/git.py +6 -3
index 526668b..99d7dc1 100644
@@ -344,12 +344,15 @@ class Git(FetchMethod):
         output = self._lsremote(ud, d, "")
         # Tags of the form ^{} may not work, need to fallback to other form
         if ud.unresolvedrev[name][:5] == "refs/":
-            head = ud.unresolvedrev[name]
-            tag = ud.unresolvedrev[name]
+            search_list = [ud.unresolvedrev[name],
+                           ud.unresolvedrev[name] + "^{}"]
+        elif ud.unresolvedrev[name] == 'HEAD':
+            search_list = ['HEAD']
         else:
             head = "refs/heads/%s" % ud.unresolvedrev[name]
             tag = "refs/tags/%s" % ud.unresolvedrev[name]
-        for s in [head, tag + "^{}", tag]:
+            search_list = [head, tag + "^{}", tag]
+        for s in search_list:
             for l in output.split('\n'):
                 if s in l:
                     return l.split()[0]
Signature · 1 line
2.6.6
#1 lore raw

Ping! I haven't seen any comments regarding this one, and, it hasn't been merged, either.
- Markus

Quoted 56 lines · Markus Lehtonen

This change makes it possible to e.g. build a currently checked out revision of a local Git repository and use AUTOREV. It will be possible
to build HEAD of remote repositories, too, of course, but this is probably not that practical.

In order to use this one must also use the nobranch parameter, i.e. have
'branch=HEAD;nobranch=1' in the SRC_URI, because 'HEAD' is really not a
Git branch as such. The wording in "branch=HEAD;nobranch=1" is probably a
bit counter-intuitive and illogical but this seems to be the only easy
way to make this work without complicating the fetcher even further. Another solution would be e.g. to introduce an alternative 'ref' parameter which could be used in place of 'branch' to give any ref. The
effect would basically be the same (with better wording) with yet a bit
more complex fetcher code.

[YOCTO #9351]

---
 lib/bb/fetch2/git.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/bb/fetch2/git.py +0 -0
index 526668b..99d7dc1 100644
@@ -344,12 +344,15 @@ class Git(FetchMethod):
         output = self._lsremote(ud, d, "")
         # Tags of the form ^{} may not work, need to fallback to

other form

         if ud.unresolvedrev[name][:5] == "refs/":
lib/bb/fetch2/git.py +6 -3
-            head = ud.unresolvedrev[name]
-            tag = ud.unresolvedrev[name]
+            search_list = [ud.unresolvedrev[name],
+                           ud.unresolvedrev[name] + "^{}"]
+        elif ud.unresolvedrev[name] == 'HEAD':
+            search_list = ['HEAD']
         else:
             head = "refs/heads/%s" % ud.unresolvedrev[name]
             tag = "refs/tags/%s" % ud.unresolvedrev[name]
-        for s in [head, tag + "^{}", tag]:
+            search_list = [head, tag + "^{}", tag]
+        for s in search_list:
             for l in output.split('\n'):
                 if s in l:
                     return l.split()[0]
Signature · 1 line
2.6.6
#2 lore raw

Markus,

Sorry I missed this email -- thanks for the patch. I'll test with my use case and try to report back in a few days.

Thanks,
Cliff

Quoted 68 lines · Markus Lehtonen

Ping! I haven't seen any comments regarding this one, and, it hasn't been merged, either.
- Markus

Quoted 54 lines · Markus Lehtonen

This change makes it possible to e.g. build a currently checked out revision of a local Git repository and use AUTOREV. It will be possible
to build HEAD of remote repositories, too, of course, but this is probably not that practical.

In order to use this one must also use the nobranch parameter, i.e. have
'branch=HEAD;nobranch=1' in the SRC_URI, because 'HEAD' is really not a
Git branch as such. The wording in "branch=HEAD;nobranch=1" is probably a
bit counter-intuitive and illogical but this seems to be the only easy
way to make this work without complicating the fetcher even further. Another solution would be e.g. to introduce an alternative 'ref' parameter which could be used in place of 'branch' to give any ref. The
effect would basically be the same (with better wording) with yet a bit
more complex fetcher code.

[YOCTO #9351]

---
 lib/bb/fetch2/git.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/bb/fetch2/git.py +0 -0
index 526668b..99d7dc1 100644
@@ -344,12 +344,15 @@ class Git(FetchMethod):
         output = self._lsremote(ud, d, "")
         # Tags of the form ^{} may not work, need to fallback to

other form

         if ud.unresolvedrev[name][:5] == "refs/":
lib/bb/fetch2/git.py +6 -4
-            head = ud.unresolvedrev[name]
-            tag = ud.unresolvedrev[name]
+            search_list = [ud.unresolvedrev[name],
+                           ud.unresolvedrev[name] + "^{}"]
+        elif ud.unresolvedrev[name] == 'HEAD':
+            search_list = ['HEAD']
         else:
             head = "refs/heads/%s" % ud.unresolvedrev[name]
             tag = "refs/tags/%s" % ud.unresolvedrev[name]
-        for s in [head, tag + "^{}", tag]:
+            search_list = [head, tag + "^{}", tag]
+        for s in search_list:
             for l in output.split('\n'):
                 if s in l:
                     return l.split()[0]
--
Quoted 2 lines

2.6.6

--
_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel