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

Function remove_path_from_gitmodules

submodule.c:146–172  ·  view source on GitHub ↗

* Try to remove the "submodule. " section from .gitmodules where the given * path is configured. Return 0 only if a .gitmodules file was found, a section * with the correct path= setting was found and we could remove it. */

Source from the content-addressed store, hash-verified

144 * with the correct path=<path> setting was found and we could remove it.
145 */
146int remove_path_from_gitmodules(const char *path)
147{
148 struct strbuf sect = STRBUF_INIT;
149 const struct submodule *submodule;
150
151 if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */
152 return -1;
153
154 if (is_gitmodules_unmerged(the_repository->index))
155 die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
156
157 submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
158 if (!submodule || !submodule->name) {
159 warning(_("Could not find section in .gitmodules where path=%s"), path);
160 return -1;
161 }
162 strbuf_addstr(&sect, "submodule.");
163 strbuf_addstr(&sect, submodule->name);
164 if (repo_config_rename_section_in_file(the_repository, GITMODULES_FILE, sect.buf, NULL) < 0) {
165 /* Maybe the user already did that, don't error out here */
166 warning(_("Could not remove .gitmodules entry for %s"), path);
167 strbuf_release(&sect);
168 return -1;
169 }
170 strbuf_release(&sect);
171 return 0;
172}
173
174void stage_updated_gitmodules(struct index_state *istate)
175{

Callers 1

cmd_rmFunction · 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