From: Junio C Hamano Date: Thu, 15 Jul 2010 19:07:18 +0000 (-0700) Subject: Merge branch 'jn/grep-open' X-Git-Tag: v1.7.2~23 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a7d7853463ae77fc3c8511283f5c896bee673b33?ds=inline;hp=-c Merge branch 'jn/grep-open' * jn/grep-open: grep -O: Do not pass color sequences as filenames to pager --- a7d7853463ae77fc3c8511283f5c896bee673b33 diff --combined builtin/grep.c index 232cd1ce07,7a9427d357..597f76bc42 --- a/builtin/grep.c +++ b/builtin/grep.c @@@ -770,15 -770,11 +770,15 @@@ static int file_callback(const struct o 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); @@@ -1001,6 -997,7 +1001,7 @@@ int cmd_grep(int argc, const char **arg 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;