MCPcopy Index your code
hub / github.com/git/git / grep_config

Function grep_config

grep.c:59–111  ·  view source on GitHub ↗

* Read the configuration file once and store it in * the grep_defaults template. */

Source from the content-addressed store, hash-verified

57 * the grep_defaults template.
58 */
59int grep_config(const char *var, const char *value,
60 const struct config_context *ctx, void *cb)
61{
62 struct grep_opt *opt = cb;
63 const char *slot;
64
65 if (userdiff_config(var, value) < 0)
66 return -1;
67
68 if (!strcmp(var, "grep.extendedregexp")) {
69 opt->extended_regexp_option = git_config_bool(var, value);
70 return 0;
71 }
72
73 if (!strcmp(var, "grep.patterntype")) {
74 opt->pattern_type_option = parse_pattern_type_arg(var, value);
75 return 0;
76 }
77
78 if (!strcmp(var, "grep.linenumber")) {
79 opt->linenum = git_config_bool(var, value);
80 return 0;
81 }
82 if (!strcmp(var, "grep.column")) {
83 opt->columnnum = git_config_bool(var, value);
84 return 0;
85 }
86
87 if (!strcmp(var, "grep.fullname")) {
88 opt->relative = !git_config_bool(var, value);
89 return 0;
90 }
91
92 if (!strcmp(var, "color.grep"))
93 opt->color = git_config_colorbool(var, value);
94 if (!strcmp(var, "color.grep.match")) {
95 if (grep_config("color.grep.matchcontext", value, ctx, cb) < 0)
96 return -1;
97 if (grep_config("color.grep.matchselected", value, ctx, cb) < 0)
98 return -1;
99 } else if (skip_prefix(var, "color.grep.", &slot)) {
100 int i = LOOKUP_CONFIG(color_grep_slots, slot);
101 char *color;
102
103 if (i < 0)
104 return -1;
105 color = opt->colors[i];
106 if (!value)
107 return config_error_nonbool(var);
108 return color_parse(value, color);
109 }
110 return 0;
111}
112
113void grep_init(struct grep_opt *opt, struct repository *repo)
114{

Callers 1

grep_cmd_configFunction · 0.85

Calls 6

userdiff_configFunction · 0.85
git_config_boolFunction · 0.85
parse_pattern_type_argFunction · 0.85
git_config_colorboolFunction · 0.85
config_error_nonboolFunction · 0.85
color_parseFunction · 0.85

Tested by

no test coverage detected