All of lore.kernel.org
 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 1/2] diff: add a creation factor argument
Date: Tue, 04 Feb 2025 17:44:16 +0100	[thread overview]
Message-ID: <20250204-creation-factor-v1-1-9988d594a018@bootlin.com> (raw)
In-Reply-To: <20250204-creation-factor-v1-0-9988d594a018@bootlin.com>

When using git range-diff it is possible to override the creation factor
when git considers a large change a total rewrite (and so showing no
diff at all), or a change so small it shouldn't be considered.

This parameter is only possible to set from command-line, it has no
global option associated to it within Git's config, so add a
--creation-factor parameter to b4 to achieve the same behavior.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 src/b4/command.py | 2 ++
 src/b4/diff.py    | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/b4/command.py b/src/b4/command.py
index 2bdd785..0485196 100644
--- a/src/b4/command.py
+++ b/src/b4/command.py
@@ -287,6 +287,8 @@ def setup_parser() -> argparse.ArgumentParser:
                          help='Force color output even when writing to file')
     sp_diff.add_argument('-m', '--compare-am-mboxes', dest='ambox', nargs=2, default=None,
                          help='Compare two mbx files prepared with "b4 am"')
+    sp_diff.add_argument('--creation-factor', default=None, type=int,
+                         help='Creation factor integer passed to git range-diff')
     sp_diff.set_defaults(func=cmd_diff)
 
     # b4 kr
diff --git a/src/b4/diff.py b/src/b4/diff.py
index 1de3063..83fad67 100644
--- a/src/b4/diff.py
+++ b/src/b4/diff.py
@@ -156,7 +156,10 @@ def main(cmdargs: argparse.Namespace) -> None:
         logger.critical('---')
         logger.critical('Could not create fake-am range for upper series v%s', user.revision)
         sys.exit(1)
-    grdcmd = 'git range-diff %.12s..%.12s %.12s..%.12s' % (lsc, lec, usc, uec)
+    cf_str = ""
+    if cmdargs.creation_factor:
+        cf_str = f"--creation-factor={cmdargs.creation_factor} "
+    grdcmd = 'git range-diff %s%.12s..%.12s %.12s..%.12s' % (cf_str, lsc, lec, usc, uec)
     if cmdargs.nodiff:
         logger.info('Success, to compare v%s and v%s:', lser.revision, user.revision)
         logger.info(f'    {grdcmd}')
@@ -167,6 +170,8 @@ def main(cmdargs: argparse.Namespace) -> None:
     gitargs = ['range-diff', f'{lsc}..{lec}', f'{usc}..{uec}']
     if cmdargs.outdiff is None or cmdargs.color:
         gitargs.append('--color')
+    if cmdargs.creation_factor:
+        gitargs.append(cf_str.strip())
     ecode, rdiff = b4.git_run_command(cmdargs.gitdir, gitargs)
     if ecode > 0:
         logger.critical('Unable to generate diff')

-- 
2.47.0


  reply	other threads:[~2025-02-04 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 16:44 [PATCH b4 0/2] prep, diff: support overriding range-diff creation factor Antonin Godard
2025-02-04 16:44 ` Antonin Godard [this message]
2025-02-04 16:44 ` [PATCH b4 2/2] prep: add creation-factor argument Antonin Godard
2025-02-06 18:09 ` [PATCH b4 0/2] prep, diff: support overriding range-diff creation factor Konstantin Ryabitsev
2025-02-07  7:58   ` Antonin Godard

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=20250204-creation-factor-v1-1-9988d594a018@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.