Skip to content

Commit 188e9e2

Browse files
avargitster
authored andcommitted
pickaxe: die when -G and --pickaxe-regex are combined
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 d01d8c6 (Support for pickaxe matching regular expressions, 2006-03-29) only the -S option existed. Then when -G was added in f506b8e (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 5bc3f0b (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7cd5d5b commit 188e9e2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,6 +4628,9 @@ void diff_setup_done(struct diff_options *options)
46284628
if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
46294629
die(_("-G, -S and --find-object are mutually exclusive"));
46304630

4631+
if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK))
4632+
die(_("-G and --pickaxe-regex are mutually exclusive, use --pickaxe-regex with -S"));
4633+
46314634
/*
46324635
* Most of the time we can say "there are changes"
46334636
* only by checking if there are changed paths, but

diff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ int git_config_rename(const char *var, const char *value);
556556
#define DIFF_PICKAXE_KINDS_MASK (DIFF_PICKAXE_KIND_S | \
557557
DIFF_PICKAXE_KIND_G | \
558558
DIFF_PICKAXE_KIND_OBJFIND)
559+
#define DIFF_PICKAXE_KINDS_G_REGEX_MASK (DIFF_PICKAXE_KIND_G | \
560+
DIFF_PICKAXE_REGEX)
559561

560562
#define DIFF_PICKAXE_IGNORE_CASE 32
561563

t/t4209-log-pickaxe.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ test_expect_success 'usage' '
6666
grep "mutually exclusive" err
6767
'
6868

69+
test_expect_success 'usage: --pickaxe-regex' '
70+
test_expect_code 128 git log -Gregex --pickaxe-regex 2>err &&
71+
grep "mutually exclusive" err
72+
'
73+
6974
test_expect_success 'usage: --no-pickaxe-regex' '
7075
cat >expect <<-\EOF &&
7176
fatal: unrecognized argument: --no-pickaxe-regex

0 commit comments

Comments
 (0)