tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Zahka <daniel.zahka@gmail.com>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
	 Daniel Zahka <daniel.zahka@gmail.com>
Subject: [PATCH b4] main: ez: add option to use git notes for prep and send commands
Date: Mon, 03 Nov 2025 12:46:59 -0800	[thread overview]
Message-ID: <20251103-notes-v1-1-6c5a561e4ba6@gmail.com> (raw)

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.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
---
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(-)

diff --git a/docs/contributor/prep.rst b/docs/contributor/prep.rst
index 18c710d..836fb53 100644
--- a/docs/contributor/prep.rst
+++ b/docs/contributor/prep.rst
@@ -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.
diff --git a/docs/contributor/send.rst b/docs/contributor/send.rst
index 54ed474..121f2d9 100644
--- a/docs/contributor/send.rst
+++ b/docs/contributor/send.rst
@@ -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.
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 7689550..89b81c2 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -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')
diff --git a/src/b4/command.py b/src/b4/command.py
index 0114197..7974ec1 100644
--- a/src/b4/command.py
+++ b/src/b4/command.py
@@ -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')
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 57bc1ca..c649ee0 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -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,
--  
Daniel Zahka <daniel.zahka@gmail.com>


             reply	other threads:[~2025-11-03 20:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03 20:46 Daniel Zahka [this message]
2025-11-03 21:34 ` [PATCH b4] main: ez: add option to use git notes for prep and send commands Konstantin Ryabitsev
2025-11-03 21:58   ` Daniel Zahka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251103-notes-v1-1-6c5a561e4ba6@gmail.com \
    --to=daniel.zahka@gmail.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).