Skip to content

Commit b07bdd3

Browse files
opera-jlgitster
authored andcommitted
remote rm: delete remote configuration as the last
When removing a remote, delete the remote-tracking branches before deleting the remote configuration. This way, if the operation fails or is aborted while deleting the remote-tracking branches, the command can be rerun to complete the operation. Signed-off-by: Jens Lindström <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a28f16 commit b07bdd3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

builtin/remote.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,6 @@ static int rm(int argc, const char **argv)
789789
known_remotes.to_delete = remote;
790790
for_each_remote(add_known_remote, &known_remotes);
791791

792-
strbuf_addf(&buf, "remote.%s", remote->name);
793-
if (git_config_rename_section(buf.buf, NULL) < 1)
794-
return error(_("Could not remove config section '%s'"), buf.buf);
795-
796792
read_branches();
797793
for (i = 0; i < branch_list.nr; i++) {
798794
struct string_list_item *item = branch_list.items + i;
@@ -837,6 +833,12 @@ static int rm(int argc, const char **argv)
837833
}
838834
string_list_clear(&skipped, 0);
839835

836+
if (!result) {
837+
strbuf_addf(&buf, "remote.%s", remote->name);
838+
if (git_config_rename_section(buf.buf, NULL) < 1)
839+
return error(_("Could not remove config section '%s'"), buf.buf);
840+
}
841+
840842
return result;
841843
}
842844

0 commit comments

Comments
 (0)