Merge branch 'ab/grep-lose-opt-regflags'
authorJunio C Hamano <gitster@pobox.com>
Thu, 13 Jul 2017 23:14:54 +0000 (16:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Jul 2017 23:14:54 +0000 (16:14 -0700)
Code cleanup.

* ab/grep-lose-opt-regflags:
grep: remove redundant REG_NEWLINE when compiling fixed regex
grep: remove regflags from the public grep_opt API
grep: remove redundant and verbose re-assignments to 0
grep: remove redundant "fixed" field re-assignment to 0
grep: adjust a redundant grep pattern type assignment
grep: remove redundant double assignment to 0

1  2 
builtin/grep.c
revision.c
diff --combined builtin/grep.c
index 0d6e669732dadd574c69924578bf85ed6e6aeaf8,b6829664397e11e59433c6af3671c8f0c2d9c977..7e79eb1a754a5f604829e3e9e6d98d83712be9b6
@@@ -4,7 -4,6 +4,7 @@@
   * Copyright (c) 2006 Junio C Hamano
   */
  #include "cache.h"
 +#include "repository.h"
  #include "config.h"
  #include "blob.h"
  #include "tree.h"
@@@ -543,7 -542,7 +543,7 @@@ static void compile_submodule_options(c
         * submodule process has its own thread pool.
         */
        argv_array_pushf(&submodule_options, "--threads=%d",
 -                       (num_threads + 1) / 2);
 +                       DIV_ROUND_UP(num_threads, 2));
  
        /* Add Pathspecs */
        argv_array_push(&submodule_options, "--");
@@@ -644,11 -643,11 +644,11 @@@ static int grep_submodule_launch(struc
  static int grep_submodule(struct grep_opt *opt, const struct object_id *oid,
                          const char *filename, const char *path)
  {
 -      if (!is_submodule_initialized(path))
 +      if (!is_submodule_active(the_repository, path))
                return 0;
        if (!is_submodule_populated_gently(path, NULL)) {
                /*
 -               * If searching history, check for the presense of the
 +               * If searching history, check for the presence of the
                 * submodule's gitdir before skipping the submodule.
                 */
                if (oid) {
@@@ -1170,8 -1169,6 +1170,6 @@@ int cmd_grep(int argc, const char **arg
  
        if (!opt.pattern_list)
                die(_("no pattern given."));
-       if (!opt.fixed && opt.ignore_case)
-               opt.regflags |= REG_ICASE;
  
        /*
         * We have to find "--" in a separate pass, because its presence
diff --combined revision.c
index 9ff120b30518aa2b3f7cc214a1c921d739108d7c,207103d21188270af83a365064afbc1412524162..6603af944486db6d5ec560dd9c655d24c31ce9e9
@@@ -1142,7 -1142,7 +1142,7 @@@ int ref_excluded(struct string_list *re
        if (!ref_excludes)
                return 0;
        for_each_string_list_item(item, ref_excludes) {
 -              if (!wildmatch(item->string, path, 0, NULL))
 +              if (!wildmatch(item->string, path, 0))
                        return 1;
        }
        return 0;
@@@ -1362,7 -1362,6 +1362,6 @@@ void init_revisions(struct rev_info *re
        init_grep_defaults();
        grep_init(&revs->grep_filter, prefix);
        revs->grep_filter.status_only = 1;
-       revs->grep_filter.regflags = REG_NEWLINE;
  
        diff_setup(&revs->diffopt);
        if (prefix && !revs->diffopt.prefix) {
@@@ -2022,7 -2021,6 +2021,6 @@@ static int handle_revision_opt(struct r
                revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;
        } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
                revs->grep_filter.ignore_case = 1;
-               revs->grep_filter.regflags |= REG_ICASE;
                DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
        } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
                revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;