* 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. */
| 144 | * with the correct path=<path> setting was found and we could remove it. |
| 145 | */ |
| 146 | int 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(§, "submodule."); |
| 163 | strbuf_addstr(§, 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(§); |
| 168 | return -1; |
| 169 | } |
| 170 | strbuf_release(§); |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | void stage_updated_gitmodules(struct index_state *istate) |
| 175 | { |
no test coverage detected