Skip to contentSkip to conversation

buildman: Support upstream branch name containing /

PATCH In review Simon Glass 2 participants 2 messages Oct 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 buildman: Support upstream branch name containing /

Buildman assumes that branch names do not have a slash in them, since slash is used to delimit remotes, etc. This means that a branch called 'WIP/tryme' in remote dm ends up being 'tryme'.

Adjust the logic a little, to try to accommodate this.

For now, no tests are added for this behaviour.

---

 tools/patman/gitutil.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/patman/gitutil.py +3 -2
index b0a12f2e8c06..10ea5ff39f5c 100644
@@ -147,8 +147,9 @@ def get_upstream(git_dir, branch):
     if remote == '.':
         return merge, None
     elif remote and merge:
-        leaf = merge.split('/')[-1]
-        return '%s/%s' % (remote, leaf), None
+        # Drop the initial refs/heads from merge
+        leaf = merge.split('/', maxsplit=2)[2:]
+        return '%s/%s' % (remote, '/'.join(leaf)), None
     else:
         raise ValueError("Cannot determine upstream branch for branch "
                          "'%s' remote='%s', merge='%s'"
Signature · 1 line
2.42.0.820.g83a721a137-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Simon Glass

Buildman assumes that branch names do not have a slash in them, since slash is used to delimit remotes, etc. This means that a branch called 'WIP/tryme' in remote dm ends up being 'tryme'.

Adjust the logic a little, to try to accommodate this.

For now, no tests are added for this behaviour.

---

 tools/patman/gitutil.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/patman/gitutil.py +0 -0
index b0a12f2e8c06..10ea5ff39f5c 100644
@@ -147,8 +147,9 @@ def get_upstream(git_dir, branch):
     if remote == '.':

tools/patman/gitutil.py def get_upstream(git_dir, branch): · line 155

Quoted 10 lines
tools/patman/gitutil.py +3 -2
         return merge, None
     elif remote and merge:
-        leaf = merge.split('/')[-1]
-        return '%s/%s' % (remote, leaf), None
+        # Drop the initial refs/heads from merge
+        leaf = merge.split('/', maxsplit=2)[2:]
+        return '%s/%s' % (remote, '/'.join(leaf)), None
     else:
         raise ValueError("Cannot determine upstream branch for branch "
                          "'%s' remote='%s', merge='%s'"

Thanks for looking at this. Poking at this a little more and what git does/doesn't allow in names, and also does/doesn't tell us easily via git config, I think this is correct.

Signature · 1 line
Tom