]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pickaxe: die when -G and --pickaxe-regex are combined
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 12 Apr 2021 17:15:14 +0000 (19:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 May 2021 03:47:31 +0000 (12:47 +0900)
When the -G and --pickaxe-regex options are combined we simply ignore
the --pickaxe-regex option. Let's die instead as suggested by our
documentation, since -G is always a regex.

When --pickaxe-regex was added in d01d8c6782 (Support for pickaxe
matching regular expressions, 2006-03-29) only the -S option
existed. Then when -G was added in f506b8e8b5 (git log/diff: add
-G<regexp> that greps in the patch text, 2010-08-23) neither the
documentation for --pickaxe-regex was updated accordingly, nor was
something like this assertion added.

Since 5bc3f0b567 (diffcore-pickaxe doc: document -S and -G properly,
2013-05-31) we've claimed that --pickaxe-regex should only be used
with -S, but have silently tolerated combining it with -G, let's die
instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diff.h
t/t4209-log-pickaxe.sh

diff --git a/diff.c b/diff.c
index 4acccd9d7edbb9e097a1d5b8b3bc2ff0ebf3acdb..f9e86bca04e7634c85385f7227147e9aa5296c97 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4628,6 +4628,9 @@ void diff_setup_done(struct diff_options *options)
        if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
                die(_("-G, -S and --find-object are mutually exclusive"));
 
+       if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK))
+               die(_("-G and --pickaxe-regex are mutually exclusive, use --pickaxe-regex with -S"));
+
        /*
         * Most of the time we can say "there are changes"
         * only by checking if there are changed paths, but
diff --git a/diff.h b/diff.h
index c8f3faea8aa9ad9d627ec61326d89cd8f2ea27c5..5e110d349be1eed69e271a8893cf7923043b11cb 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -556,6 +556,8 @@ int git_config_rename(const char *var, const char *value);
 #define DIFF_PICKAXE_KINDS_MASK (DIFF_PICKAXE_KIND_S | \
                                 DIFF_PICKAXE_KIND_G | \
                                 DIFF_PICKAXE_KIND_OBJFIND)
+#define DIFF_PICKAXE_KINDS_G_REGEX_MASK (DIFF_PICKAXE_KIND_G | \
+                                        DIFF_PICKAXE_REGEX)
 
 #define DIFF_PICKAXE_IGNORE_CASE       32
 
index 532bb875f02f4cc8860c6cf9e7afb5eb01d56f43..772c6c1a7c82bc01b0a3d4f8b90fd3c79b6a72a4 100755 (executable)
@@ -66,6 +66,11 @@ test_expect_success 'usage' '
        grep "mutually exclusive" err
 '
 
+test_expect_success 'usage: --pickaxe-regex' '
+       test_expect_code 128 git log -Gregex --pickaxe-regex 2>err &&
+       grep "mutually exclusive" err
+'
+
 test_expect_success 'usage: --no-pickaxe-regex' '
        cat >expect <<-\EOF &&
        fatal: unrecognized argument: --no-pickaxe-regex