diff options
Diffstat (limited to 'submodule.c')
| -rw-r--r-- | submodule.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/submodule.c b/submodule.c index 3a0dfc417c..f0ddb31e8f 100644 --- a/submodule.c +++ b/submodule.c @@ -1,5 +1,5 @@ - -#include "cache.h" +#include "git-compat-util.h" +#include "abspath.h" #include "repository.h" #include "config.h" #include "submodule-config.h" @@ -7,6 +7,9 @@ #include "dir.h" #include "diff.h" #include "commit.h" +#include "environment.h" +#include "gettext.h" +#include "hex.h" #include "revision.h" #include "run-command.h" #include "diffcore.h" @@ -14,15 +17,18 @@ #include "string-list.h" #include "oid-array.h" #include "strvec.h" -#include "blob.h" #include "thread-utils.h" -#include "quote.h" +#include "path.h" #include "remote.h" #include "worktree.h" #include "parse-options.h" -#include "object-store.h" +#include "object-file.h" +#include "object-name.h" +#include "object-store-ll.h" #include "commit-reach.h" -#include "shallow.h" +#include "read-cache-ll.h" +#include "setup.h" +#include "trace2.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; static int initialized_fetch_ref_tips; @@ -65,7 +71,7 @@ int is_writing_gitmodules_ok(void) { struct object_id oid; return file_exists(GITMODULES_FILE) || - (get_oid(GITMODULES_INDEX, &oid) < 0 && get_oid(GITMODULES_HEAD, &oid) < 0); + (repo_get_oid(the_repository, GITMODULES_INDEX, &oid) < 0 && repo_get_oid(the_repository, GITMODULES_HEAD, &oid) < 0); } /* @@ -274,8 +280,7 @@ int is_tree_submodule_active(struct repository *repo, free(key); /* submodule.active is set */ - sl = repo_config_get_value_multi(repo, "submodule.active"); - if (sl) { + if (!repo_config_get_string_multi(repo, "submodule.active", &sl)) { struct pathspec ps; struct strvec args = STRVEC_INIT; const struct string_list_item *item; @@ -587,7 +592,12 @@ static void show_submodule_header(struct diff_options *o, (!is_null_oid(two) && !*right)) message = "(commits not present)"; - *merge_bases = repo_get_merge_bases(sub, *left, *right); + *merge_bases = NULL; + if (repo_get_merge_bases(sub, *left, *right, merge_bases) < 0) { + message = "(corrupt repository)"; + goto output_header; + } + if (*merge_bases) { if ((*merge_bases)->item == *left) fast_forward = 1; @@ -1625,7 +1635,7 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf, if (!task->repo) { strbuf_addf(err, _("Could not access submodule '%s' at commit %s\n"), cs_data->path, - find_unique_abbrev(cs_data->super_oid, DEFAULT_ABBREV)); + repo_find_unique_abbrev(the_repository, cs_data->super_oid, DEFAULT_ABBREV)); fetch_task_release(task); free(task); @@ -1636,8 +1646,8 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf, strbuf_addf(err, _("Fetching submodule %s%s at commit %s\n"), spf->prefix, task->sub->path, - find_unique_abbrev(cs_data->super_oid, - DEFAULT_ABBREV)); + repo_find_unique_abbrev(the_repository, cs_data->super_oid, + DEFAULT_ABBREV)); spf->changed_count++; /* @@ -1682,8 +1692,6 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, task = get_fetch_task_from_changed(spf, err); if (task) { - struct strbuf submodule_prefix = STRBUF_INIT; - child_process_init(cp); cp->dir = task->repo->gitdir; prepare_submodule_repo_env_in_gitdir(&cp->env); @@ -1693,15 +1701,11 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, strvec_pushv(&cp->args, task->git_args.v); strvec_pushv(&cp->args, spf->args.v); strvec_push(&cp->args, task->default_argv); - strvec_push(&cp->args, "--submodule-prefix"); + strvec_pushf(&cp->args, "--submodule-prefix=%s%s/", + spf->prefix, task->sub->path); - strbuf_addf(&submodule_prefix, "%s%s/", - spf->prefix, - task->sub->path); - strvec_push(&cp->args, submodule_prefix.buf); *task_cb = task; - strbuf_release(&submodule_prefix); string_list_insert(&spf->seen_submodule_names, task->sub->name); return 1; } @@ -1709,12 +1713,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, if (spf->oid_fetch_tasks_nr) { struct fetch_task *task = spf->oid_fetch_tasks[spf->oid_fetch_tasks_nr - 1]; - struct strbuf submodule_prefix = STRBUF_INIT; spf->oid_fetch_tasks_nr--; - strbuf_addf(&submodule_prefix, "%s%s/", - spf->prefix, task->sub->path); - child_process_init(cp); prepare_submodule_repo_env_in_gitdir(&cp->env); cp->git_cmd = 1; @@ -1723,8 +1723,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, strvec_init(&cp->args); strvec_pushv(&cp->args, spf->args.v); strvec_push(&cp->args, "on-demand"); - strvec_push(&cp->args, "--submodule-prefix"); - strvec_push(&cp->args, submodule_prefix.buf); + strvec_pushf(&cp->args, "--submodule-prefix=%s%s/", + spf->prefix, task->sub->path); /* NEEDSWORK: have get_default_remote from submodule--helper */ strvec_push(&cp->args, "origin"); @@ -1732,14 +1732,13 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, append_oid_to_argv, &cp->args); *task_cb = task; - strbuf_release(&submodule_prefix); return 1; } return 0; } -static int fetch_start_failure(struct strbuf *err, +static int fetch_start_failure(struct strbuf *err UNUSED, void *cb, void *task_cb) { struct submodule_parallel_fetch *spf = cb; @@ -1760,7 +1759,7 @@ static int commit_missing_in_sub(const struct object_id *oid, void *data) return type != OBJ_COMMIT; } -static int fetch_finish(int retvalue, struct strbuf *err, +static int fetch_finish(int retvalue, struct strbuf *err UNUSED, void *cb, void *task_cb) { struct submodule_parallel_fetch *spf = cb; |
