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

Function get_next_submodule

submodule.c:1681–1748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1679}
1680
1681static int get_next_submodule(struct child_process *cp, struct strbuf *err,
1682 void *data, void **task_cb)
1683{
1684 struct submodule_parallel_fetch *spf = data;
1685 struct fetch_task *task =
1686 get_fetch_task_from_index(spf, err);
1687 if (!task)
1688 task = get_fetch_task_from_changed(spf, err);
1689
1690 if (task) {
1691 child_process_init(cp);
1692 cp->dir = task->repo->gitdir;
1693 prepare_submodule_repo_env_in_gitdir(&cp->env);
1694 cp->git_cmd = 1;
1695 strvec_init(&cp->args);
1696 if (task->git_args.nr)
1697 strvec_pushv(&cp->args, task->git_args.v);
1698 strvec_pushv(&cp->args, spf->args.v);
1699 strvec_push(&cp->args, task->default_argv);
1700 strvec_pushf(&cp->args, "--submodule-prefix=%s%s/",
1701 spf->prefix, task->sub->path);
1702
1703 *task_cb = task;
1704
1705 string_list_insert(&spf->seen_submodule_names, task->sub->name);
1706 return 1;
1707 }
1708
1709 if (spf->oid_fetch_tasks_nr) {
1710 struct fetch_task *task =
1711 spf->oid_fetch_tasks[spf->oid_fetch_tasks_nr - 1];
1712 struct child_process cp_remote = CHILD_PROCESS_INIT;
1713 struct strbuf remote_name = STRBUF_INIT;
1714 spf->oid_fetch_tasks_nr--;
1715
1716 child_process_init(cp);
1717 prepare_submodule_repo_env_in_gitdir(&cp->env);
1718 cp->git_cmd = 1;
1719 cp->dir = task->repo->gitdir;
1720
1721 strvec_init(&cp->args);
1722 strvec_pushv(&cp->args, spf->args.v);
1723 strvec_push(&cp->args, "on-demand");
1724 strvec_pushf(&cp->args, "--submodule-prefix=%s%s/",
1725 spf->prefix, task->sub->path);
1726
1727 cp_remote.git_cmd = 1;
1728 strvec_pushl(&cp_remote.args, "submodule--helper",
1729 "get-default-remote", task->sub->path, NULL);
1730
1731 if (!capture_command(&cp_remote, &remote_name, 0)) {
1732 strbuf_trim_trailing_newline(&remote_name);
1733 strvec_push(&cp->args, remote_name.buf);
1734 } else {
1735 /* Fallback to "origin" if the helper fails */
1736 strvec_push(&cp->args, "origin");
1737 }
1738 strbuf_release(&remote_name);

Callers

nothing calls this directly

Calls 14

child_process_initFunction · 0.85
strvec_initFunction · 0.85
strvec_pushvFunction · 0.85
strvec_pushFunction · 0.85
strvec_pushfFunction · 0.85
string_list_insertFunction · 0.85
strvec_pushlFunction · 0.85
capture_commandFunction · 0.85

Tested by

no test coverage detected