Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/grep.c b/grep.c
index 8421dc5548..35e12e43c0 100644
--- a/grep.c
+++ b/grep.c
@@ -19,27 +19,6 @@ static void std_output(struct grep_opt *opt, const void *buf, size_t size)
fwrite(buf, size, 1, stdout);
}
-static struct grep_opt grep_defaults = {
- .relative = 1,
- .pathname = 1,
- .max_depth = -1,
- .pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED,
- .colors = {
- [GREP_COLOR_CONTEXT] = "",
- [GREP_COLOR_FILENAME] = GIT_COLOR_MAGENTA,
- [GREP_COLOR_FUNCTION] = "",
- [GREP_COLOR_LINENO] = GIT_COLOR_GREEN,
- [GREP_COLOR_COLUMNNO] = GIT_COLOR_GREEN,
- [GREP_COLOR_MATCH_CONTEXT] = GIT_COLOR_BOLD_RED,
- [GREP_COLOR_MATCH_SELECTED] = GIT_COLOR_BOLD_RED,
- [GREP_COLOR_SELECTED] = "",
- [GREP_COLOR_SEP] = GIT_COLOR_CYAN,
- },
- .only_matching = 0,
- .color = -1,
- .output = std_output,
-};
-
static const char *color_grep_slots[] = {
[GREP_COLOR_CONTEXT] = "context",
[GREP_COLOR_FILENAME] = "filename",
@@ -75,20 +54,12 @@ define_list_config_array_extra(color_grep_slots, {"match"});
*/
int grep_config(const char *var, const char *value, void *cb)
{
- struct grep_opt *opt = &grep_defaults;
+ struct grep_opt *opt = cb;
const char *slot;
if (userdiff_config(var, value) < 0)
return -1;
- /*
- * The instance of grep_opt that we set up here is copied by
- * grep_init() to be used by each individual invocation.
- * When populating a new field of this structure here, be
- * sure to think about ownership -- e.g., you might need to
- * override the shallow copy in grep_init() with a deep copy.
- */
-
if (!strcmp(var, "grep.extendedregexp")) {
opt->extended_regexp_option = git_config_bool(var, value);
return 0;
@@ -134,14 +105,10 @@ int grep_config(const char *var, const char *value, void *cb)
return 0;
}
-/*
- * Initialize one instance of grep_opt and copy the
- * default values from the template we read the configuration
- * information in an earlier call to git_config(grep_config).
- */
void grep_init(struct grep_opt *opt, struct repository *repo)
{
- *opt = grep_defaults;
+ struct grep_opt blank = GREP_OPT_INIT;
+ memcpy(opt, &blank, sizeof(*opt));
opt->repo = repo;
opt->pattern_tail = &opt->pattern_list;