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

Function connect_wt_gitdir_in_nested

dir.c:4058–4106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4056}
4057
4058static void connect_wt_gitdir_in_nested(const char *sub_worktree,
4059 const char *sub_gitdir)
4060{
4061 int i;
4062 struct repository subrepo;
4063 struct strbuf sub_wt = STRBUF_INIT;
4064 struct strbuf sub_gd = STRBUF_INIT;
4065
4066 const struct submodule *sub;
4067
4068 /* If the submodule has no working tree, we can ignore it. */
4069 if (repo_init(&subrepo, sub_gitdir, sub_worktree))
4070 return;
4071
4072 if (repo_read_index(&subrepo) < 0)
4073 die(_("index file corrupt in repo %s"), subrepo.gitdir);
4074
4075 /* TODO: audit for interaction with sparse-index. */
4076 ensure_full_index(subrepo.index);
4077 for (i = 0; i < subrepo.index->cache_nr; i++) {
4078 const struct cache_entry *ce = subrepo.index->cache[i];
4079
4080 if (!S_ISGITLINK(ce->ce_mode))
4081 continue;
4082
4083 while (i + 1 < subrepo.index->cache_nr &&
4084 !strcmp(ce->name, subrepo.index->cache[i + 1]->name))
4085 /*
4086 * Skip entries with the same name in different stages
4087 * to make sure an entry is returned only once.
4088 */
4089 i++;
4090
4091 sub = submodule_from_path(&subrepo, null_oid(the_hash_algo), ce->name);
4092 if (!sub || !is_submodule_active(&subrepo, ce->name))
4093 /* .gitmodules broken or inactive sub */
4094 continue;
4095
4096 strbuf_reset(&sub_wt);
4097 strbuf_reset(&sub_gd);
4098 strbuf_addf(&sub_wt, "%s/%s", sub_worktree, sub->path);
4099 submodule_name_to_gitdir(&sub_gd, &subrepo, sub->name);
4100
4101 connect_work_tree_and_git_dir(sub_wt.buf, sub_gd.buf, 1);
4102 }
4103 strbuf_release(&sub_wt);
4104 strbuf_release(&sub_gd);
4105 repo_clear(&subrepo);
4106}
4107
4108void connect_work_tree_and_git_dir(const char *work_tree_,
4109 const char *git_dir_,

Callers 1

Calls 12

repo_initFunction · 0.85
repo_read_indexFunction · 0.85
ensure_full_indexFunction · 0.85
submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
is_submodule_activeFunction · 0.85
strbuf_addfFunction · 0.85
submodule_name_to_gitdirFunction · 0.85
strbuf_releaseFunction · 0.85
repo_clearFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected