return NULL;
}
-int check_submodule_name(const char *name)
-{
- /* Disallow empty names */
- if (!*name)
- return -1;
-
- /*
- * Look for '..' as a path component. Check both '/' and '\\' as
- * separators rather than is_dir_sep(), because we want the name rules
- * to be consistent across platforms.
- */
- goto in_component; /* always start inside component */
- while (*name) {
- char c = *name++;
- if (c == '/' || c == '\\') {
-in_component:
- if (name[0] == '.' && name[1] == '.' &&
- (!name[2] || name[2] == '/' || name[2] == '\\'))
- return -1;
- }
- }
-
- return 0;
-}
-
static int name_and_item_from_var(const char *var, struct strbuf *name,
struct strbuf *item)
{
return 0;
strbuf_add(name, subsection, subsection_len);
- if (check_submodule_name(name->buf) < 0) {
- warning(_("ignoring suspicious submodule name: %s"), name->buf);
- strbuf_release(name);
- return 0;
- }
-
strbuf_addstr(item, key);
return 1;
commit_string, name, option);
}
-static void warn_command_line_option(const char *var, const char *value)
-{
- warning(_("ignoring '%s' which may be interpreted as"
- " a command-line option: %s"), var, value);
-}
-
struct parse_config_parameter {
struct submodule_cache *cache;
const unsigned char *treeish_name;
int overwrite;
};
-/*
- * 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.
- */
static int parse_config(const char *var, const char *value, void *data)
{
struct parse_config_parameter *me = data;
if (!strcmp(item.buf, "path")) {
if (!value)
ret = config_error_nonbool(var);
- else if (looks_like_command_line_option(value))
- warn_command_line_option(var, value);
else if (!me->overwrite && submodule->path)
warn_multiple_config(me->treeish_name, submodule->name,
"path");
} else if (!strcmp(item.buf, "url")) {
if (!value) {
ret = config_error_nonbool(var);
- } else if (looks_like_command_line_option(value)) {
- warn_command_line_option(var, value);
} else if (!me->overwrite && submodule->url) {
warn_multiple_config(me->treeish_name, submodule->name,
"url");
warn_multiple_config(me->treeish_name, submodule->name,
"update");
else if (parse_submodule_update_strategy(value,
- &submodule->update_strategy) < 0 ||
- submodule->update_strategy.type == SM_UPDATE_COMMAND)
- die(_("invalid value for %s"), var);
+ &submodule->update_strategy) < 0)
+ die(_("invalid value for %s"), var);
} else if (!strcmp(item.buf, "shallow")) {
if (!me->overwrite && submodule->recommend_shallow != -1)
warn_multiple_config(me->treeish_name, submodule->name,