Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
grep: set default output method
author
Brandon Williams
<bmwill@google.com>
Fri, 17 Mar 2017 18:41:54 +0000
(11:41 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 17 Mar 2017 19:18:41 +0000
(12:18 -0700)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e6fac7f
)
diff --git
a/grep.c
b/grep.c
index 0dbdc1d007893042dc1005478f3023eed4ecfc12..56ef0ecbfffd8531a5b88585efc0c9097e182ed6 100644
(file)
--- a/
grep.c
+++ b/
grep.c
@@
-12,6
+12,11
@@
static int grep_source_is_binary(struct grep_source *gs);
static struct grep_opt grep_defaults;
static struct grep_opt grep_defaults;
+static void std_output(struct grep_opt *opt, const void *buf, size_t size)
+{
+ fwrite(buf, size, 1, stdout);
+}
+
/*
* Initialize the grep_defaults template with hardcoded defaults.
* We could let the compiler do this, but without C99 initializers
/*
* Initialize the grep_defaults template with hardcoded defaults.
* We could let the compiler do this, but without C99 initializers
@@
-42,6
+47,7
@@
void init_grep_defaults(void)
color_set(opt->color_selected, "");
color_set(opt->color_sep, GIT_COLOR_CYAN);
opt->color = -1;
color_set(opt->color_selected, "");
color_set(opt->color_sep, GIT_COLOR_CYAN);
opt->color = -1;
+ opt->output = std_output;
}
static int parse_pattern_type_arg(const char *opt, const char *arg)
}
static int parse_pattern_type_arg(const char *opt, const char *arg)
@@
-152,6
+158,7
@@
void grep_init(struct grep_opt *opt, const char *prefix)
opt->pathname = def->pathname;
opt->regflags = def->regflags;
opt->relative = def->relative;
opt->pathname = def->pathname;
opt->regflags = def->regflags;
opt->relative = def->relative;
+ opt->output = def->output;
color_set(opt->color_context, def->color_context);
color_set(opt->color_filename, def->color_filename);
color_set(opt->color_context, def->color_context);
color_set(opt->color_filename, def->color_filename);
@@
-1379,11
+1386,6
@@
static int look_ahead(struct grep_opt *opt,
return 0;
}
return 0;
}
-static void std_output(struct grep_opt *opt, const void *buf, size_t size)
-{
- fwrite(buf, size, 1, stdout);
-}
-
static int fill_textconv_grep(struct userdiff_driver *driver,
struct grep_source *gs)
{
static int fill_textconv_grep(struct userdiff_driver *driver,
struct grep_source *gs)
{