* 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. */
| 114 | * with the correct path=<oldpath> setting was found and we could update it. |
| 115 | */ |
| 116 | int 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 |
no test coverage detected