Skip to content

Commit d26ec88

Browse files
avargitster
authored andcommitted
pickaxe: die when --find-object and --pickaxe-all are combined
Neither the --pickaxe-all documentation nor --find-object's has ever suggested that you can combine the two. See f506b8e (git log/diff: add -G<regexp> that greps in the patch text, 2010-08-23) and 15af58c (diffcore: add a pickaxe option to find a specific blob, 2018-01-04). But we've silently tolerated it, which makes the logic in diffcore_pickaxe() harder to reason about. Let's assert that we won't have the two combined. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 188e9e2 commit d26ec88

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4631,6 +4631,9 @@ void diff_setup_done(struct diff_options *options)
46314631
if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK))
46324632
die(_("-G and --pickaxe-regex are mutually exclusive, use --pickaxe-regex with -S"));
46334633

4634+
if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK))
4635+
die(_("---pickaxe-all and --find-object are mutually exclusive, use --pickaxe-all with -G and -S"));
4636+
46344637
/*
46354638
* Most of the time we can say "there are changes"
46364639
* 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
@@ -558,6 +558,8 @@ int git_config_rename(const char *var, const char *value);
558558
DIFF_PICKAXE_KIND_OBJFIND)
559559
#define DIFF_PICKAXE_KINDS_G_REGEX_MASK (DIFF_PICKAXE_KIND_G | \
560560
DIFF_PICKAXE_REGEX)
561+
#define DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK (DIFF_PICKAXE_ALL | \
562+
DIFF_PICKAXE_KIND_OBJFIND)
561563

562564
#define DIFF_PICKAXE_IGNORE_CASE 32
563565

t/t4209-log-pickaxe.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ test_expect_success 'usage' '
6363
grep "mutually exclusive" err &&
6464
6565
test_expect_code 128 git log -Sstring --find-object=HEAD 2>err &&
66+
grep "mutually exclusive" err &&
67+
68+
test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err &&
6669
grep "mutually exclusive" err
6770
'
6871

0 commit comments

Comments
 (0)