diff mbox series

[07/11] devtool: fix misleading error when srcrev is on no branch

Message ID 20261124171807.74394-8-jaipaul.cheernam@est.tech
State New
Headers show
Series Upgrades on 24th November | expand

Commit Message

Jaipaul Cheernam Nov. 24, 2026, 5:18 p.m. UTC
If srcrev is only reachable from a tag, devtool wrongly reports it as
found on multiple branches. Report that no remote branch contains it.

Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
---
 scripts/lib/devtool/upgrade.py | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 6cec34d2d5..46fb1be5d5 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -241,6 +241,9 @@  def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
         srcsubdir_rel = params.get('destsuffix', 'git')
         if not srcbranch:
             check_branch, check_branch_err = __run('git branch -r --contains %s' % srcrev)
+            if not check_branch.strip():
+                # srcrev is not on any remote branch (e.g. it is only reachable from a tag)
+                raise DevtoolError('Revision %s was not found on any remote branch.\nIt may only be reachable through a tag' % srcrev)
             get_branch = [x.strip() for x in check_branch.splitlines()]
             # Remove HEAD reference point and drop remote prefix
             get_branch = [x.split('/', 1)[1] for x in get_branch if not x.startswith('origin/HEAD')]