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

Function parse_config

submodule-config.c:564–668  ·  view source on GitHub ↗

* Parse a config item from .gitmodules. * * This does not handle submodule-related configuration from the main * config store (.git/config, etc). Callers are responsible for * checking for overrides in the main config store when appropriate. */

Source from the content-addressed store, hash-verified

562 * checking for overrides in the main config store when appropriate.
563 */
564static int parse_config(const char *var, const char *value,
565 const struct config_context *ctx UNUSED, void *data)
566{
567 struct parse_config_parameter *me = data;
568 struct submodule *submodule;
569 struct strbuf name = STRBUF_INIT, item = STRBUF_INIT;
570 int ret = 0;
571
572 /* this also ensures that we only parse submodule entries */
573 if (!name_and_item_from_var(var, &name, &item))
574 return 0;
575
576 submodule = lookup_or_create_by_name(me->cache,
577 me->gitmodules_oid,
578 name.buf);
579
580 if (!strcmp(item.buf, "path")) {
581 if (!value)
582 ret = config_error_nonbool(var);
583 else if (looks_like_command_line_option(value))
584 warn_command_line_option(var, value);
585 else if (!me->overwrite && submodule->path)
586 warn_multiple_config(me->treeish_name, submodule->name,
587 "path");
588 else {
589 if (submodule->path)
590 cache_remove_path(me->cache, submodule);
591 free((void *) submodule->path);
592 submodule->path = xstrdup(value);
593 cache_put_path(me->cache, submodule);
594 }
595 } else if (!strcmp(item.buf, "fetchrecursesubmodules")) {
596 /* when parsing worktree configurations we can die early */
597 int die_on_error = is_null_oid(me->gitmodules_oid);
598 if (!me->overwrite &&
599 submodule->fetch_recurse != RECURSE_SUBMODULES_NONE)
600 warn_multiple_config(me->treeish_name, submodule->name,
601 "fetchrecursesubmodules");
602 else
603 submodule->fetch_recurse = parse_fetch_recurse(
604 var, value,
605 die_on_error);
606 } else if (!strcmp(item.buf, "ignore")) {
607 if (!value)
608 ret = config_error_nonbool(var);
609 else if (!me->overwrite && submodule->ignore)
610 warn_multiple_config(me->treeish_name, submodule->name,
611 "ignore");
612 else if (strcmp(value, "untracked") &&
613 strcmp(value, "dirty") &&
614 strcmp(value, "all") &&
615 strcmp(value, "none"))
616 warning("Invalid parameter '%s' for config option "
617 "'submodule.%s.ignore'", value, name.buf);
618 else {
619 free((void *) submodule->ignore);
620 submodule->ignore = xstrdup(value);
621 }

Callers 1

gitmodules_cbFunction · 0.70

Calls 15

name_and_item_from_varFunction · 0.85
lookup_or_create_by_nameFunction · 0.85
config_error_nonboolFunction · 0.85
warn_command_line_optionFunction · 0.85
warn_multiple_configFunction · 0.85
cache_remove_pathFunction · 0.85
xstrdupFunction · 0.85
cache_put_pathFunction · 0.85
is_null_oidFunction · 0.85
parse_fetch_recurseFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected