Code

i18n: git-submodule "path not initialized" message
[git.git] / builtin / grep.c
index 5b8f30d3ed472bb74f1b992b5098a08f5d5377a1..3ee2ec51def59695813ee14f104d142a62d530b6 100644 (file)
@@ -302,6 +302,19 @@ static int grep_config(const char *var, const char *value, void *cb)
        default: return 0;
        }
 
+       if (!strcmp(var, "grep.extendedregexp")) {
+               if (git_config_bool(var, value))
+                       opt->regflags |= REG_EXTENDED;
+               else
+                       opt->regflags &= ~REG_EXTENDED;
+               return 0;
+       }
+
+       if (!strcmp(var, "grep.linenumber")) {
+               opt->linenum = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "color.grep"))
                opt->color = git_config_colorbool(var, value, -1);
        else if (!strcmp(var, "color.grep.context"))
@@ -401,10 +414,10 @@ static void *load_file(const char *filename, size_t *sz)
        err_ret:
                if (errno != ENOENT)
                        error(_("'%s': %s"), filename, strerror(errno));
-               return 0;
+               return NULL;
        }
        if (!S_ISREG(st.st_mode))
-               return 0;
+               return NULL;
        *sz = xsize_t(st.st_size);
        i = open(filename, O_RDONLY);
        if (i < 0)
@@ -414,7 +427,7 @@ static void *load_file(const char *filename, size_t *sz)
                error(_("'%s': short read %s"), filename, strerror(errno));
                close(i);
                free(data);
-               return 0;
+               return NULL;
        }
        close(i);
        data[*sz] = 0;
@@ -520,18 +533,18 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
 static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                     struct tree_desc *tree, struct strbuf *base, int tn_len)
 {
-       int hit = 0, matched = 0;
+       int hit = 0, match = 0;
        struct name_entry entry;
        int old_baselen = base->len;
 
        while (tree_entry(tree, &entry)) {
                int te_len = tree_entry_len(entry.path, entry.sha1);
 
-               if (matched != 2) {
-                       matched = tree_entry_interesting(&entry, base, tn_len, pathspec);
-                       if (matched == -1)
-                               break; /* no more matches */
-                       if (!matched)
+               if (match != 2) {
+                       match = tree_entry_interesting(&entry, base, tn_len, pathspec);
+                       if (match < 0)
+                               break;
+                       if (match == 0)
                                continue;
                }