Browse Source

diff: migrate diff_flags.pickaxe_ignore_case to a pickaxe_opts bit

Currently flags for pickaxing are found in different places. Unify the
flags into the `pickaxe_opts` field, which will contain any pickaxe related
flags.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Stefan Beller 7 years ago committed by Junio C Hamano
parent
commit
c1ddc4610c
  1. 3
      diff.h
  2. 6
      diffcore-pickaxe.c
  3. 2
      revision.c

3
diff.h

@ -91,7 +91,6 @@ struct diff_flags {
unsigned override_submodule_config:1; unsigned override_submodule_config:1;
unsigned dirstat_by_line:1; unsigned dirstat_by_line:1;
unsigned funccontext:1; unsigned funccontext:1;
unsigned pickaxe_ignore_case:1;
unsigned default_follow_renames:1; unsigned default_follow_renames:1;
}; };


@ -327,6 +326,8 @@ extern void diff_setup_done(struct diff_options *);
#define DIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */ #define DIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */
#define DIFF_PICKAXE_KIND_G 8 /* grep in the patch */ #define DIFF_PICKAXE_KIND_G 8 /* grep in the patch */


#define DIFF_PICKAXE_IGNORE_CASE 32

extern void diffcore_std(struct diff_options *); extern void diffcore_std(struct diff_options *);
extern void diffcore_fix_diff_index(struct diff_options *); extern void diffcore_fix_diff_index(struct diff_options *);



6
diffcore-pickaxe.c

@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)


if (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) { if (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {
int cflags = REG_EXTENDED | REG_NEWLINE; int cflags = REG_EXTENDED | REG_NEWLINE;
if (o->flags.pickaxe_ignore_case) if (o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE)
cflags |= REG_ICASE; cflags |= REG_ICASE;
regcomp_or_die(&regex, needle, cflags); regcomp_or_die(&regex, needle, cflags);
regexp = &regex; regexp = &regex;
} else if (o->flags.pickaxe_ignore_case && } else if (o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE &&
has_non_ascii(needle)) { has_non_ascii(needle)) {
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;
int cflags = REG_NEWLINE | REG_ICASE; int cflags = REG_NEWLINE | REG_ICASE;
@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)
strbuf_release(&sb); strbuf_release(&sb);
regexp = &regex; regexp = &regex;
} else { } else {
kws = kwsalloc(o->flags.pickaxe_ignore_case kws = kwsalloc(o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE
? tolower_trans_tbl : NULL); ? tolower_trans_tbl : NULL);
kwsincr(kws, needle, strlen(needle)); kwsincr(kws, needle, strlen(needle));
kwsprep(kws); kwsprep(kws);

2
revision.c

@ -2076,7 +2076,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE; revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;
} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) { } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
revs->grep_filter.ignore_case = 1; revs->grep_filter.ignore_case = 1;
revs->diffopt.flags.pickaxe_ignore_case = 1; revs->diffopt.pickaxe_opts |= DIFF_PICKAXE_IGNORE_CASE;
} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) { } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED; revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;
} else if (!strcmp(arg, "--perl-regexp") || !strcmp(arg, "-P")) { } else if (!strcmp(arg, "--perl-regexp") || !strcmp(arg, "-P")) {

Loading…
Cancel
Save