Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
From: Antonin Godard <antonin.godard@bootlin.com>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
	 Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Antonin Godard <antonin.godard@bootlin.com>
Subject: [PATCH b4 v3 2/2] prep: support passing arguments to git range-diff
Date: Tue, 04 Mar 2025 14:00:30 +0100	[thread overview]
Message-ID: <20250304-creation-factor-v3-2-d6515180b7e5@bootlin.com> (raw)
In-Reply-To: <20250304-creation-factor-v3-0-d6515180b7e5@bootlin.com>

Like the previous commit ("diff: support passing arguments to git
range-diff"), make it possible to pass additional options to git
range-diff, which can be useful to modify the command's behavior.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 docs/contributor/prep.rst | 6 ++++++
 src/b4/command.py         | 2 ++
 src/b4/ez.py              | 9 +++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/docs/contributor/prep.rst b/docs/contributor/prep.rst
index df8582426850df88b9e174e6429837e1eb49f792..18c710dd415794f5c1587b3375d86c8761c57602 100644
--- a/docs/contributor/prep.rst
+++ b/docs/contributor/prep.rst
@@ -494,3 +494,9 @@ modifying defaults for some of these flags.
 ``-e ENROLL_BASE, --enroll ENROLL_BASE``
   Enrolls your current branch to be b4-prep managed. Requires the name
   of the branch to use as the fork-point tracking base.
+
+``--range-diff-opts RANGE_DIFF_OPTS``
+  Additional arguments passed to ``git range-diff`` when comparing series with
+  ``--compare-to``. For example::
+
+      b4 prep --compare-to v1 --range-diff-opts "--creation-factor=80 --no-dual-color"
diff --git a/src/b4/command.py b/src/b4/command.py
index df2ec55ee9da6440b4176bee14ef011aa717f6f0..4b71d8a81f7e4160632d76a8c993fc396efc8d53 100644
--- a/src/b4/command.py
+++ b/src/b4/command.py
@@ -309,6 +309,8 @@ def setup_parser() -> argparse.ArgumentParser:
                          help='Additional prefixes to add to those already defined')
     sp_prep.add_argument('-C', '--no-cache', dest='nocache', action='store_true', default=False,
                          help='Do not use local cache when performing remote queries')
+    sp_prep.add_argument('--range-diff-opts', default=None, type=str,
+                         help='Arguments passed to git range-diff when comparing series')
 
     spp_g = sp_prep.add_mutually_exclusive_group()
     spp_g.add_argument('-p', '--format-patch', metavar='OUTPUT_DIR',
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 61918f57722e817781b74d7a700fea030bc2145f..156926aae33c84106ba8197e43dba249cf698c8b 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -2550,7 +2550,7 @@ def force_revision(forceto: int) -> None:
     store_cover(cover, tracking)
 
 
-def compare(compareto: str, execvp: bool = True) -> Union[str, None]:
+def compare(compareto: str, execvp: bool = True, range_diff_opts: str = None) -> Union[str, None]:
     cover, tracking = load_cover()
     # Try the new format first
     tagname, revision = get_sent_tagname(tracking['series']['change-id'], SENT_TAG_PREFIX, compareto)
@@ -2580,6 +2580,11 @@ def compare(compareto: str, execvp: bool = True) -> Union[str, None]:
     lines = b4.git_get_command_lines(None, gitargs)
     curr_end = lines[0]
     grdcmd = ['git', 'range-diff', '%.12s..%.12s' % (prev_start, prev_end), '%.12s..%.12s' % (curr_start, curr_end)]
+    if range_diff_opts:
+        sp = shlex.shlex(range_diff_opts, posix=True)
+        sp.whitespace_split = True
+        rd_opts = list(sp)
+        grdcmd = grdcmd + rd_opts
     logger.debug('Running %s', ' '.join(grdcmd))
     if execvp:
         # We exec range-diff and let it take over
@@ -2792,7 +2797,7 @@ def cmd_prep(cmdargs: argparse.Namespace) -> None:
         return format_patch(cmdargs.format_patch)
 
     if cmdargs.compare_to:
-        return compare(cmdargs.compare_to)
+        return compare(cmdargs.compare_to, range_diff_opts=cmdargs.range_diff_opts)
 
     if cmdargs.enroll_base and cmdargs.new_series_name:
         logger.critical('CRITICAL: -n NEW_SERIES_NAME and -e [ENROLL_BASE] can not be used together.')

-- 
2.47.0


  parent reply	other threads:[~2025-03-04 13:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 13:00 [PATCH b4 v3 0/2] prep, diff: support passing arguments to range-diff Antonin Godard
2025-03-04 13:00 ` [PATCH b4 v3 1/2] diff: support passing arguments to git range-diff Antonin Godard
2025-03-04 13:00 ` Antonin Godard [this message]
2025-03-05 20:46 ` [PATCH b4 v3 0/2] prep, diff: support passing arguments to range-diff Konstantin Ryabitsev

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=20250304-creation-factor-v3-2-d6515180b7e5@bootlin.com \
    --to=antonin.godard@bootlin.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=thomas.petazzoni@bootlin.com \
    --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