* 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. */
| 562 | * checking for overrides in the main config store when appropriate. |
| 563 | */ |
| 564 | static 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 | } |
no test coverage detected