git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] grep: set default output method

From
BWBrandon Williams <bmwill@google.com>
Date
Mar 17, 2017, 18:41 UTC
Message-ID
<20170317184155.128674-1-bmwill@google.com>
In-Reply-To
<20170317182403.GA110341@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 grep.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/grep.c b/grep.c
index 0dbdc1d00..56ef0ecbf 100644
--- 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 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
@@ -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;
+	opt->output = std_output;
 }
 
 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->output = def->output;
 
 	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;
 }
 
-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)
 {
-- 
2.12.0.367.g23dc2f6d3c-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 4 of 12 in “grep: fix build with no thread support”
  1. grep: fix build with no thread supportRahul Bedarkar, Mar 17, 2017
  2. Junio C HamanoMar 17, 2017
  3. Brandon WilliamsMar 17, 2017
  4. 1/2 grep: set default output methodBrandon Williams, Mar 17, 2017
  5. 2/2 grep: fix builds with with no thread supportBrandon Williams, Mar 17, 2017
  6. Jonathan NiederMar 17, 2017
  7. Rahul BedarkarMar 20, 2017
  8. Brandon WilliamsMar 17, 2017
  9. Jeff KingMar 17, 2017
  10. Brandon WilliamsMar 17, 2017
  11. Jeff KingMar 17, 2017
  12. Brandon WilliamsMar 17, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.