@@ -290,8 +290,8 @@ def setup_parser() -> argparse.ArgumentParser:
ag_prepn.add_argument('-F', '--from-thread', metavar='MSGID', dest='msgid',
help='When creating a new branch, use this thread')
ag_prepe = sp_prep.add_argument_group('Enroll existing branch', 'Enroll existing branch for prep work')
- ag_prepe.add_argument('-e', '--enroll', dest='enroll_base',
- help='Enroll current branch, using the passed tag, branch, or commit as fork base')
+ ag_prepe.add_argument('-e', '--enroll', dest='enroll_base', nargs='?', const='@{upstream}',
+ help='Enroll current branch, using its configured upstream branch as fork base, or the passed tag, branch, or commit')
sp_prep.set_defaults(func=cmd_prep)
# b4 trailers
@@ -373,7 +373,11 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
# Convert @{upstream}, @{push} to an abbreviated ref
gitargs = ['rev-parse', '--abbrev-ref', '--verify', enroll_base]
ecode, out = b4.git_run_command(None, gitargs)
- if out:
+ if ecode > 0:
+ if enroll_base == '@{upstream}' or enroll_base == '@{u}':
+ logger.critical('CRITICAL: current branch has no configured upstream')
+ sys.exit(1)
+ elif out:
enroll_base = out.strip()
# Is it a branch?
gitargs = ['show-ref', f'refs/heads/{enroll_base}', f'refs/remotes/{enroll_base}']