Code

Merge branch 'mm/rebase-i-exec'
[git.git] / builtin / grep.c
index 4b8ddbe0d52d3aa9719372400c24959dc7efd8c2..cf6c29fa42d96f8bc8282e779617a60d40796166 100644 (file)
@@ -770,11 +770,15 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
        if (!patterns)
                die_errno("cannot open '%s'", arg);
        while (strbuf_getline(&sb, patterns, '\n') == 0) {
+               char *s;
+               size_t len;
+
                /* ignore empty line like grep does */
                if (sb.len == 0)
                        continue;
-               append_grep_pattern(grep_opt, strbuf_detach(&sb, NULL), arg,
-                                   ++lno, GREP_PATTERN);
+
+               s = strbuf_detach(&sb, &len);
+               append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN);
        }
        fclose(patterns);
        strbuf_release(&sb);
@@ -832,7 +836,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        struct grep_opt opt;
        struct object_array list = { 0, 0, NULL };
        const char **paths = NULL;
-       struct string_list path_list = { NULL, 0, 0, 0 };
+       struct string_list path_list = STRING_LIST_INIT_NODUP;
        int i;
        int dummy;
        int nongit = 0, use_index = 1;
@@ -997,6 +1001,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        if (show_in_pager == default_pager)
                show_in_pager = git_pager(1);
        if (show_in_pager) {
+               opt.color = 0;
                opt.name_only = 1;
                opt.null_following_name = 1;
                opt.output_priv = &path_list;