2
1

0001-grep-set-default-output-method.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 379642bcd8d89db52feba88a651e4e56d6ac5767 Mon Sep 17 00:00:00 2001
  2. From: Brandon Williams <bmwill@google.com>
  3. Date: Fri, 17 Mar 2017 11:41:54 -0700
  4. Subject: [PATCH] grep: set default output method
  5. Signed-off-by: Brandon Williams <bmwill@google.com>
  6. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
  8. ---
  9. grep.c | 12 +++++++-----
  10. 1 file changed, 7 insertions(+), 5 deletions(-)
  11. diff --git a/grep.c b/grep.c
  12. index 0dbdc1d..56ef0ec 100644
  13. --- a/grep.c
  14. +++ b/grep.c
  15. @@ -12,6 +12,11 @@ static int grep_source_is_binary(struct grep_source *gs);
  16. static struct grep_opt grep_defaults;
  17. +static void std_output(struct grep_opt *opt, const void *buf, size_t size)
  18. +{
  19. + fwrite(buf, size, 1, stdout);
  20. +}
  21. +
  22. /*
  23. * Initialize the grep_defaults template with hardcoded defaults.
  24. * We could let the compiler do this, but without C99 initializers
  25. @@ -42,6 +47,7 @@ void init_grep_defaults(void)
  26. color_set(opt->color_selected, "");
  27. color_set(opt->color_sep, GIT_COLOR_CYAN);
  28. opt->color = -1;
  29. + opt->output = std_output;
  30. }
  31. static int parse_pattern_type_arg(const char *opt, const char *arg)
  32. @@ -152,6 +158,7 @@ void grep_init(struct grep_opt *opt, const char *prefix)
  33. opt->pathname = def->pathname;
  34. opt->regflags = def->regflags;
  35. opt->relative = def->relative;
  36. + opt->output = def->output;
  37. color_set(opt->color_context, def->color_context);
  38. color_set(opt->color_filename, def->color_filename);
  39. @@ -1379,11 +1386,6 @@ static int look_ahead(struct grep_opt *opt,
  40. return 0;
  41. }
  42. -static void std_output(struct grep_opt *opt, const void *buf, size_t size)
  43. -{
  44. - fwrite(buf, size, 1, stdout);
  45. -}
  46. -
  47. static int fill_textconv_grep(struct userdiff_driver *driver,
  48. struct grep_source *gs)
  49. {
  50. --
  51. 2.6.2