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

Function parse_fsync_components

environment.c:237–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235};
236
237static enum fsync_component parse_fsync_components(const char *var, const char *string)
238{
239 enum fsync_component current = FSYNC_COMPONENTS_PLATFORM_DEFAULT;
240 enum fsync_component positive = 0, negative = 0;
241
242 while (string) {
243 size_t len;
244 const char *ep;
245 int negated = 0;
246 int found = 0;
247
248 string = string + strspn(string, ", \t\n\r");
249 ep = strchrnul(string, ',');
250 len = ep - string;
251 if (!strcmp(string, "none")) {
252 current = FSYNC_COMPONENT_NONE;
253 goto next_name;
254 }
255
256 if (*string == '-') {
257 negated = 1;
258 string++;
259 len--;
260 if (!len)
261 warning(_("invalid value for variable %s"), var);
262 }
263
264 if (!len)
265 break;
266
267 for (size_t i = 0; i < ARRAY_SIZE(fsync_component_names); ++i) {
268 const struct fsync_component_name *n = &fsync_component_names[i];
269
270 if (strncmp(n->name, string, len))
271 continue;
272
273 found = 1;
274 if (negated)
275 negative |= n->component_bits;
276 else
277 positive |= n->component_bits;
278 }
279
280 if (!found) {
281 char *component = xstrndup(string, len);
282 warning(_("ignoring unknown core.fsync component '%s'"), component);
283 free(component);
284 }
285
286next_name:
287 string = ep;
288 }
289
290 return (current & ~negative) | positive;
291}
292
293int git_default_core_config(const char *var, const char *value,
294 const struct config_context *ctx, void *cb)

Callers 1

git_default_core_configFunction · 0.85

Calls 2

warningFunction · 0.85
xstrndupFunction · 0.85

Tested by

no test coverage detected