main: ez: add option to use git notes for prep and send commands
PATCH 1/1 main: ez: add option to use git notes for prep and send commands
It can be useful to keep a per-patch changelog using git notes. Allow git notes to be added to commits during export from the b4 prep and send commands.
---
Notes:
v1:
- a test note to export with b4
docs/contributor/prep.rst | 6 ++++++ docs/contributor/send.rst | 5 +++++ src/b4/__init__.py | 6 +++++- src/b4/command.py | 4 ++++ src/b4/ez.py | 16 ++++++++++------ 5 files changed, 30 insertions(+), 7 deletions(-)
docs/contributor/prep.rst +6 -0
@@ -500,3 +500,9 @@ modifying defaults for some of these flags. ``--compare-to``. For example:: b4 prep --compare-to v1 --range-diff-opts "--creation-factor=80 --no-dual-color" + +``--notes`` + Include git notes in the patches when formatting with ``-p``. By default, + git notes are not included in patch output. When this flag is enabled, + notes from the default ``refs/notes/commits`` ref will be appended after + the commit message in each patch.
docs/contributor/send.rst +5 -0
@@ -324,3 +324,8 @@ Command line flags ``--resend V`` Resend the specified previously sent version. +``--notes`` + Include git notes in the patches. By default, git notes are not included + in patch emails. When this flag is enabled, notes from the default + ``refs/notes/commits`` ref will be appended after the commit message in + each patch.
src/b4/__init__.py +5 -1
@@ -3658,7 +3658,8 @@ def git_range_to_patches(gitdir: Optional[str], start: str, end: str, mailfrom: Optional[Tuple[str, str]] = None, extrahdrs: Optional[List[Tuple[str, str]]] = None, ignore_commits: Optional[Set[str]] = None, - limit_committer: Optional[str] = None) -> List[Tuple[str, EmailMessage]]: + limit_committer: Optional[str] = None, + include_notes: bool = False) -> List[Tuple[str, EmailMessage]]: gitargs = ['rev-list', '--no-merges', '--reverse'] if limit_committer: gitargs += ['-F', f'--committer={limit_committer}']
@@ -3686,6 +3687,9 @@ def git_range_to_patches(gitdir: Optional[str], start: str, end: str, if git_check_minimal_version("2.40"): showargs.append("--default-prefix") + if include_notes: + showargs.append('--notes') + smcfg = get_sendemail_config() if not get_git_bool(str(smcfg.get('mailmap', 'false'))): showargs.append('--no-mailmap')
src/b4/command.py +4 -0
@@ -322,6 +322,8 @@ def setup_parser() -> argparse.ArgumentParser: help='Do not use local cache') sp_prep.add_argument('--range-diff-opts', default=None, type=str, help='Arguments passed to git range-diff when comparing series') + sp_prep.add_argument('--notes', dest='include_notes', action='store_true', default=False, + help='Include git notes in patches') spp_g = sp_prep.add_mutually_exclusive_group() spp_g.add_argument('-p', '--format-patch', metavar='OUTPUT_DIR',
@@ -397,6 +399,8 @@ def setup_parser() -> argparse.ArgumentParser: help='Do not add the cryptographic attestation signature header') sp_send.add_argument('--use-web-endpoint', dest='send_web', action='store_true', default=False, help="Force going through the web endpoint") + sp_send.add_argument('--notes', dest='include_notes', action='store_true', default=False, + help='Include git notes in patches') ag_sendh = sp_send.add_argument_group('Web submission', 'Authenticate with the web submission endpoint') ag_sendh.add_argument('--web-auth-new', dest='auth_new', action='store_true', default=False, help='Initiate a new web authentication request')
src/b4/ez.py +10 -6
@@ -1550,7 +1550,7 @@ def rethread(patches: List[Tuple[str, EmailMessage]]) -> None: def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True, prefixes: Optional[List[str]] = None, usebranch: Optional[str] = None, expandprereqs: bool = True, - ) -> Tuple[List[Tuple[str, str]], List[Tuple[str, str]], str, List[Tuple[str, EmailMessage]]]: + include_notes: bool = False) -> Tuple[List[Tuple[str, str]], List[Tuple[str, str]], str, List[Tuple[str, EmailMessage]]]: cover, tracking = load_cover(strip_comments=True, usebranch=usebranch) if prefixes is None:
@@ -1583,7 +1583,8 @@ def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr msgid_tpt=msgid_tpt, seriests=seriests, mailfrom=mailfrom, - ignore_commits=ignore_commits) + ignore_commits=ignore_commits, + include_notes=include_notes) base_commit, _, _, _, shortlog, diffstat = get_series_details(start_commit=start_commit, usebranch=usebranch)
@@ -1772,9 +1773,10 @@ def get_sent_tag_as_patches(tagname: str, revision: int) \ return alltos, allccs, patches -def format_patch(output_dir: str) -> None: +def format_patch(output_dir: str, include_notes: bool = False) -> None: try: - _, _, _, patches = get_prep_branch_as_patches(thread=False, movefrom=False, addtracking=False) + _, _, _, patches = get_prep_branch_as_patches(thread=False, movefrom=False, addtracking=False, + include_notes=include_notes) except RuntimeError as ex: logger.critical('CRITICAL: Failed to convert range to patches: %s', ex) sys.exit(1)
@@ -1936,7 +1938,9 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: prefixes = None try: - todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(prefixes=prefixes) + todests, ccdests, tag_msg, patches = get_prep_branch_as_patches( + prefixes=prefixes, + include_notes=cmdargs.include_notes) except RuntimeError as ex: logger.critical('CRITICAL: Failed to convert range to patches: %s', ex) sys.exit(1)
@@ -2980,7 +2984,7 @@ def cmd_prep(cmdargs: argparse.Namespace) -> None: return cleanup(cmdargs.cleanup) if cmdargs.format_patch: - return format_patch(cmdargs.format_patch) + return format_patch(cmdargs.format_patch, include_notes=cmdargs.include_notes) if cmdargs.compare_to: range_diff_compare(cmdargs.compare_to, range_diff_opts=cmdargs.range_diff_opts)
---
base-commit: a6db3f06ce9836a7fc8921f588452804fc62bed1
change-id: 20251103-notes-01633223d1c5
Best regards,
Signature · 1 line
Daniel Zahka <[email protected]>
Quoted 3 lines · Daniel Zahka
It can be useful to keep a per-patch changelog using git notes. Allow git notes to be added to commits during export from the b4 prep and send commands.
Hi:
This has come up multiple times:
https://lore.kernel.org/tools/20250130-rich-orangutan-from-eldorado-04f621@lemur/
The answer is still the same -- until git-filter-repo does the right thing with git notes (as in, actually preserving them on rewrites), any solution using git notes is too fragile to consider using.
-K
Quoted 8 lines · Konstantin Ryabitsev
Quoted 3 lines · Daniel Zahka
It can be useful to keep a per-patch changelog using git notes. Allow git notes to be added to commits during export from the b4 prep and send commands.
Hi:
This has come up multiple times:
Quoted 7 lines
https://lore.kernel.org/tools/20250130-rich-orangutan-from-eldorado-04f621@lemur/
The answer is still the same -- until git-filter-repo does the right thing with git notes (as in, actually preserving them on rewrites), any solution using git notes is too fragile to consider using.
-K
Ah, I see. Thanks for taking a look.