Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'submodule-config.c')
-rw-r--r--submodule-config.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/submodule-config.c b/submodule-config.c
index cd7ee236a1..f4dd482abc 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,12 +1,18 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "dir.h"
+#include "environment.h"
+#include "gettext.h"
+#include "hex.h"
+#include "path.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
#include "strbuf.h"
-#include "object-store.h"
+#include "object-name.h"
+#include "object-store-ll.h"
#include "parse-options.h"
+#include "thread-utils.h"
#include "tree-walk.h"
/*
@@ -298,11 +304,14 @@ static int parse_fetch_recurse(const char *opt, const char *arg,
}
}
-int parse_submodule_fetchjobs(const char *var, const char *value)
+int parse_submodule_fetchjobs(const char *var, const char *value,
+ const struct key_value_info *kvi)
{
- int fetchjobs = git_config_int(var, value);
+ int fetchjobs = git_config_int(var, value, kvi);
if (fetchjobs < 0)
die(_("negative values not allowed for submodule.fetchJobs"));
+ if (!fetchjobs)
+ fetchjobs = online_cpus();
return fetchjobs;
}
@@ -418,7 +427,8 @@ struct parse_config_parameter {
* 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)
+static int parse_config(const char *var, const char *value,
+ const struct config_context *ctx UNUSED, void *data)
{
struct parse_config_parameter *me = data;
struct submodule *submodule;
@@ -506,7 +516,9 @@ static int parse_config(const char *var, const char *value, void *data)
submodule->recommend_shallow =
git_config_bool(var, value);
} else if (!strcmp(item.buf, "branch")) {
- if (!me->overwrite && submodule->branch)
+ if (!value)
+ ret = config_error_nonbool(var);
+ else if (!me->overwrite && submodule->branch)
warn_multiple_config(me->treeish_name, submodule->name,
"branch");
else {
@@ -533,7 +545,7 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
}
strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
- if (get_oid(rev->buf, gitmodules_oid) >= 0)
+ if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
ret = 1;
return ret;
@@ -586,7 +598,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,
if (submodule)
goto out;
- config = read_object_file(&oid, &type, &config_size);
+ config = repo_read_object_file(the_repository, &oid, &type,
+ &config_size);
if (!config || type != OBJ_BLOB)
goto out;
@@ -596,7 +609,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
parameter.gitmodules_oid = &oid;
parameter.overwrite = 0;
git_config_from_mem(parse_config, CONFIG_ORIGIN_SUBMODULE_BLOB, rev.buf,
- config, config_size, &parameter, NULL);
+ config, config_size, &parameter, CONFIG_SCOPE_UNKNOWN, NULL);
strbuf_release(&rev);
free(config);
@@ -650,7 +663,6 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
config_source.file = file;
} else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
- config_source.repo = repo;
config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
if (repo != the_repository)
add_submodule_odb_by_path(repo->objects->odb->path);
@@ -658,7 +670,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
goto out;
}
- config_with_options(fn, data, &config_source, &opts);
+ config_with_options(fn, data, &config_source, repo, &opts);
out:
free(oidstr);
@@ -666,7 +678,8 @@ out:
}
}
-static int gitmodules_cb(const char *var, const char *value, void *data)
+static int gitmodules_cb(const char *var, const char *value,
+ const struct config_context *ctx, void *data)
{
struct repository *repo = data;
struct parse_config_parameter parameter;
@@ -676,7 +689,7 @@ static int gitmodules_cb(const char *var, const char *value, void *data)
parameter.gitmodules_oid = null_oid();
parameter.overwrite = 1;
- return parse_config(var, value, &parameter);
+ return parse_config(var, value, ctx, &parameter);
}
void repo_read_gitmodules(struct repository *repo, int skip_if_read)
@@ -704,7 +717,8 @@ void gitmodules_config_oid(const struct object_id *commit_oid)
if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
git_config_from_blob_oid(gitmodules_cb, rev.buf,
- the_repository, &oid, the_repository);
+ the_repository, &oid, the_repository,
+ CONFIG_SCOPE_UNKNOWN);
}
strbuf_release(&rev);
@@ -793,7 +807,9 @@ void submodule_free(struct repository *r)
submodule_cache_clear(r->submodule_cache);
}
-static int config_print_callback(const char *var, const char *value, void *cb_data)
+static int config_print_callback(const char *var, const char *value,
+ const struct config_context *ctx UNUSED,
+ void *cb_data)
{
char *wanted_key = cb_data;
@@ -835,13 +851,15 @@ struct fetch_config {
int *recurse_submodules;
};
-static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
+static int gitmodules_fetch_config(const char *var, const char *value,
+ const struct config_context *ctx,
+ void *cb)
{
struct fetch_config *config = cb;
if (!strcmp(var, "submodule.fetchjobs")) {
if (config->max_children)
*(config->max_children) =
- parse_submodule_fetchjobs(var, value);
+ parse_submodule_fetchjobs(var, value, ctx->kvi);
return 0;
} else if (!strcmp(var, "fetch.recursesubmodules")) {
if (config->recurse_submodules)
@@ -863,11 +881,12 @@ void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
}
static int gitmodules_update_clone_config(const char *var, const char *value,
+ const struct config_context *ctx,
void *cb)
{
int *max_jobs = cb;
if (!strcmp(var, "submodule.fetchjobs"))
- *max_jobs = parse_submodule_fetchjobs(var, value);
+ *max_jobs = parse_submodule_fetchjobs(var, value, ctx->kvi);
return 0;
}