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

Function update_path_in_gitmodules

submodule.c:116–139  ·  view source on GitHub ↗

* Try to update the "path" entry in the "submodule. " section of the * .gitmodules file. Return 0 only if a .gitmodules file was found, a section * with the correct path= setting was found and we could update it. */

Source from the content-addressed store, hash-verified

114 * with the correct path=<oldpath> setting was found and we could update it.
115 */
116int update_path_in_gitmodules(const char *oldpath, const char *newpath)
117{
118 struct strbuf entry = STRBUF_INIT;
119 const struct submodule *submodule;
120 int ret;
121
122 if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */
123 return -1;
124
125 if (is_gitmodules_unmerged(the_repository->index))
126 die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
127
128 submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), oldpath);
129 if (!submodule || !submodule->name) {
130 warning(_("Could not find section in .gitmodules where path=%s"), oldpath);
131 return -1;
132 }
133 strbuf_addstr(&entry, "submodule.");
134 strbuf_addstr(&entry, submodule->name);
135 strbuf_addstr(&entry, ".path");
136 ret = config_set_in_gitmodules_file_gently(entry.buf, newpath);
137 strbuf_release(&entry);
138 return ret;
139}
140
141/*
142 * Try to remove the "submodule.<name>" section from .gitmodules where the given

Callers 1

cmd_mvFunction · 0.85

Calls 9

file_existsFunction · 0.85
is_gitmodules_unmergedFunction · 0.85
submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
warningFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected