git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Illia Bobyr <illia.bobyr@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Illia Bobyr <illia.bobyr@gmail.com>, git@vger.kernel.org
Subject: [PATCH v5 06/10] diff: --patch-{grep,modifies} arg names for -G and -S
Date: Tue, 11 Feb 2025 19:26:50 -0800	[thread overview]
Message-ID: <20250212032657.1807939-7-illia.bobyr@gmail.com> (raw)
In-Reply-To: <20250212032657.1807939-1-illia.bobyr@gmail.com>

Most arguments have both short and long versions.  Long versions are
easier to read, especially in scripts and command history.

This change mostly keeps existing uses of -G and -S as is in the tests,
documentation and help output.

Tests that check just the option parsing are duplicated to check both
short and long argument options.

Signed-off-by: Illia Bobyr <illia.bobyr@gmail.com>
---
 Documentation/diff-options.txt |  2 ++
 Documentation/gitdiffcore.txt  |  3 ++-
 diff.c                         | 12 ++++++----
 diff.h                         |  8 +++++--
 t/t4209-log-pickaxe.sh         | 42 ++++++++++++++++++++++++++++++++++
 5 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 640eb..07413d 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -650,6 +650,7 @@ Note that not all diffs can feature all types. For instance, copied and
 renamed entries cannot appear if detection for those types is disabled.
 
 `-S<string>`::
+`--patch-modifies=<string>`::
 	Look for differences that change the number of occurrences of
 	the specified _<string>_ (i.e. addition/deletion) in a file.
 	Intended for the scripter's use.
@@ -663,6 +664,7 @@ very first version of the block.
 Binary files are searched as well.
 
 `-G<regex>`::
+`--patch-grep=<regex>`::
 	Look for differences whose patch text contains added/removed
 	lines that match _<regex>_.
 +
diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index 0d7d66..e934b9 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -245,7 +245,8 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
 
 This transformation limits the set of filepairs to those that change
 specified strings between the preimage and the postimage in a certain
-way.  `-S<string>` and `-G<regex>` options are used to specify
+way.  `--patch-modifies=<string>` (`-S<string>` for short) and
+`--patch-grep=<regex>` (`-G<regex>` for short) are used to specify
 different ways these strings are sought.
 
 `-S<string>` detects filepairs whose preimage and postimage
diff --git a/diff.c b/diff.c
index bd9db..ac2cd 100644
--- a/diff.c
+++ b/diff.c
@@ -4877,15 +4877,17 @@ void diff_setup_done(struct diff_options *options)
 
 	if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
 		die(_("options '%s', '%s', and '%s' cannot be used together"),
-			"-G", "-S", "--find-object");
+			"-G/--patch-grep", "-S/--patch-modifies", "--find-object");
 
 	if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK))
 		die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s'"),
-			"-G", "--pickaxe-regex", "--pickaxe-regex", "-S");
+			"-G/--patch-grep", "--pickaxe-regex",
+			"--pickaxe-regex", "-S/--patch-modifies");
 
 	if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK))
 		die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s' and '%s'"),
-			"--pickaxe-all", "--find-object", "--pickaxe-all", "-G", "-S");
+			"--pickaxe-all", "--find-object",
+			"--pickaxe-all", "-G/--patch-grep", "-S/--patch-modifies");
 
 	/*
 	 * Most of the time we can say "there are changes"
@@ -5862,10 +5864,10 @@ struct option *add_diff_options(const struct option *opts,
 		OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index,
 			      N_("treat 'git add -N' entries as real in the index"),
 			      0, PARSE_OPT_NONEG),
-		OPT_CALLBACK_F('S', NULL, options, N_("<string>"),
+		OPT_CALLBACK_F('S', "patch-modifies", options, N_("<string>"),
 			       N_("look for differences that change the number of occurrences of the specified string"),
 			       0, diff_opt_pickaxe_string),
-		OPT_CALLBACK_F('G', NULL, options, N_("<regex>"),
+		OPT_CALLBACK_F('G', "patch-grep", options, N_("<regex>"),
 			       N_("look for differences where a patch contains the specified regex"),
 			       0, diff_opt_pickaxe_regex),
 		OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts,
diff --git a/diff.h b/diff.h
index 787bb..ed48a 100644
--- a/diff.h
+++ b/diff.h
@@ -606,8 +606,12 @@ void diffcore_fix_diff_index(void);
 "                try unchanged files as candidate for copy detection.\n" \
 "  -l<n>         limit rename attempts up to <n> paths.\n" \
 "  -O<file>      reorder diffs according to the <file>.\n" \
-"  -G<regex>     find differences where patch contains the specified regex.\n" \
-"  -S<string>    find filepair who differ in the number of occurrences of string.\n" \
+"  -G<regex>\n" \
+"  --patch-grep=<regex>\n" \
+"                find differences where patch contains the regex.\n" \
+"  -S<string>\n" \
+"  --patch-modifies=<string>\n" \
+"                find filepair who differ in the number of occurrences of string.\n" \
 "  --pickaxe-grep\n" \
 "                treat <string> as a regex in the -S argument.\n" \
 "  --pickaxe-all\n" \
diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh
index ed70c..ab14b 100755
--- a/t/t4209-log-pickaxe.sh
+++ b/t/t4209-log-pickaxe.sh
@@ -60,24 +60,48 @@ test_expect_success 'usage' '
 	test_expect_code 129 git log -S 2>err &&
 	test_grep "switch.*requires a value" err &&
 
+	test_expect_code 129 git log --patch-modifies 2>err &&
+	test_grep "option.*requires a value" err &&
+
 	test_expect_code 129 git log -G 2>err &&
 	test_grep "switch.*requires a value" err &&
 
+	test_expect_code 129 git log --patch-grep 2>err &&
+	test_grep "option.*requires a value" err &&
+
 	test_expect_code 128 git log -Gregex -Sstring 2>err &&
 	grep "cannot be used together" err &&
 
+	test_expect_code 128 git log -Gregex --patch-modifies string 2>err &&
+	grep "cannot be used together" err &&
+
+	test_expect_code 128 git log --patch-grep regex -Sstring 2>err &&
+	grep "cannot be used together" err &&
+
+	test_expect_code 128 git log --patch-grep regex --patch-modifies string 2>err &&
+	grep "cannot be used together" err &&
+
 	test_expect_code 128 git log -Gregex --find-object=HEAD 2>err &&
 	grep "cannot be used together" err &&
 
+	test_expect_code 128 git log --patch-grep regex --find-object=HEAD 2>err &&
+	grep "cannot be used together" err &&
+
 	test_expect_code 128 git log -Sstring --find-object=HEAD 2>err &&
 	grep "cannot be used together" err &&
 
+	test_expect_code 128 git log --patch-modifies string --find-object=HEAD 2>err &&
+	grep "cannot be used together" err &&
+
 	test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err &&
 	grep "cannot be used together" err
 '
 
 test_expect_success 'usage: --pickaxe-regex' '
 	test_expect_code 128 git log -Gregex --pickaxe-regex 2>err &&
+	grep "cannot be used together" err &&
+
+	test_expect_code 128 git log --patch-grep regex --pickaxe-regex 2>err &&
 	grep "cannot be used together" err
 '
 
@@ -89,7 +113,13 @@ test_expect_success 'usage: --no-pickaxe-regex' '
 	test_expect_code 128 git log -Sstring --no-pickaxe-regex 2>actual &&
 	test_cmp expect actual &&
 
+	test_expect_code 128 git log --patch-modifies string --no-pickaxe-regex 2>actual &&
+	test_cmp expect actual &&
+
 	test_expect_code 128 git log -Gregex --no-pickaxe-regex 2>err &&
+	test_cmp expect actual &&
+
+	test_expect_code 128 git log --patch-grep regex --no-pickaxe-regex 2>err &&
 	test_cmp expect actual
 '
 
@@ -104,9 +134,13 @@ test_log_icase	expect_second	--author person
 test_log_icase	expect_nomatch	--author spreon
 
 test_log	expect_nomatch	-G picked
+test_log	expect_nomatch	--patch-grep picked
 test_log	expect_second	-G Picked
+test_log	expect_second	--patch-grep Picked
 test_log_icase	expect_nomatch	-G pickle
+test_log_icase	expect_nomatch	--patch-grep pickle
 test_log_icase	expect_second	-G picked
+test_log_icase	expect_second	--patch-grep picked
 
 test_expect_success 'log -G --textconv (missing textconv tool)' '
 	echo "* diff=test" >.gitattributes &&
@@ -122,14 +156,22 @@ test_expect_success 'log -G --no-textconv (missing textconv tool)' '
 '
 
 test_log	expect_nomatch	-S picked
+test_log	expect_nomatch	--patch-modifies picked
 test_log	expect_second	-S Picked
+test_log	expect_second	--patch-modifies Picked
 test_log_icase	expect_second	-S picked
+test_log_icase	expect_second	--patch-modifies picked
 test_log_icase	expect_nomatch	-S pickle
+test_log_icase	expect_nomatch	--patch-modifies pickle
 
 test_log	expect_nomatch	-S p.cked --pickaxe-regex
+test_log	expect_nomatch	--patch-modifies p.cked --pickaxe-regex
 test_log	expect_second	-S P.cked --pickaxe-regex
+test_log	expect_second	--patch-modifies P.cked --pickaxe-regex
 test_log_icase	expect_second	-S p.cked --pickaxe-regex
+test_log_icase	expect_second	--patch-modifies p.cked --pickaxe-regex
 test_log_icase	expect_nomatch	-S p.ckle --pickaxe-regex
+test_log_icase	expect_nomatch	--patch-modifies p.ckle --pickaxe-regex
 
 test_expect_success 'log -S --textconv (missing textconv tool)' '
 	echo "* diff=test" >.gitattributes &&
-- 
2.45.2


  parent reply	other threads:[~2025-02-12  3:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  1:43 [PATCH v3 0/1] Long names for `git log -S` and `git log -G` Illia Bobyr
2025-02-06  1:43 ` [PATCH v3 1/1] diff: --patch-{modifies,grep} arg names for -S and -G Illia Bobyr
2025-02-06 20:59   ` Junio C Hamano
2025-02-12  3:26     ` Illia Bobyr
2025-02-12 17:08       ` Junio C Hamano
2025-02-06 13:04 ` [PATCH v3 0/1] Long names for `git log -S` and `git log -G` Junio C Hamano
2025-02-11  8:50 ` [PATCH v4 0/10] " Illia Bobyr
2025-02-11 18:07   ` Junio C Hamano
2025-02-12  3:28     ` Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 01/10] t/t4209-log-pickaxe: Naming typo: -G takes a regex Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 02/10] diff: -G description: Correct copy/paste error Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 03/10] diff: short help: Correct -S description Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 04/10] diff: short help: Add -G and --pickaxe-grep Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 05/10] docs: gitdiffcore: -G and -S: Use regex/string placeholders Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 06/10] diff: --patch-{grep,modifies} arg names for -G and -S Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 07/10] completion: Support --patch-{grep,modifies} Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 08/10] diff: test: Use --patch-{grep,modifies} over -G/-S Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 09/10] diff: --pickaxe-{all,regex} help: Add --patch-{grep,modifies} Illia Bobyr
2025-02-11  8:50 ` [PATCH v4 10/10] diff: docs: Use --patch-{grep,modifies} over -G/-S Illia Bobyr
2025-02-12  3:26 ` [PATCH v5 00/10] Long names for `git log -S` and `git log -G` Illia Bobyr
2025-02-12  3:26   ` [PATCH v5 01/10] t/t4209-log-pickaxe: Naming typo: -G takes a regex Illia Bobyr
2025-02-13  4:06     ` Junio C Hamano
2025-02-12  3:26   ` [PATCH v5 02/10] diff: -G description: Correct copy/paste error Illia Bobyr
2025-02-13  4:16     ` Junio C Hamano
2025-02-12  3:26   ` [PATCH v5 03/10] diff: short help: Correct -S description Illia Bobyr
2025-02-13  4:26     ` Junio C Hamano
2025-02-12  3:26   ` [PATCH v5 04/10] diff: short help: Add -G and --pickaxe-grep Illia Bobyr
2025-02-12  3:26   ` [PATCH v5 05/10] docs: gitdiffcore: -G and -S: Use regex/string placeholders Illia Bobyr
2025-02-13  4:36     ` Junio C Hamano
2025-02-12  3:26   ` Illia Bobyr [this message]
2025-02-13  5:20     ` [PATCH v5 06/10] diff: --patch-{grep,modifies} arg names for -G and -S Junio C Hamano
2025-02-12  3:26   ` [PATCH v5 07/10] completion: Support --patch-{grep,modifies} Illia Bobyr
2025-02-13  5:46     ` Junio C Hamano
2025-02-12  3:26   ` [PATCH v5 08/10] diff: test: Use --patch-{grep,modifies} over -G/-S Illia Bobyr
2025-02-12  3:26   ` [PATCH v5 09/10] diff: --pickaxe-{all,regex} help: Add --patch-{grep,modifies} Illia Bobyr
2025-02-12  3:26   ` [PATCH v5 10/10] diff: docs: Use --patch-{grep,modifies} over -G/-S Illia Bobyr

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=20250212032657.1807939-7-illia.bobyr@gmail.com \
    --to=illia.bobyr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).