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 <jl@opera.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jens Lindström committed
May 23, 2014 at 12:28 UTC
b07bdd3472886cbdd412ee3e7489273522c43133
1 file changed
+6
-4
builtin/remote.c
+6
-4
@@ -789,10 +789,6 @@ static int rm(int argc, const char **argv)
789
known_remotes.to_delete = remote;
790
for_each_remote(add_known_remote, &known_remotes);
791
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
-
792
read_branches();
793
for (i = 0; i < branch_list.nr; i++) {
794
struct string_list_item *item = branch_list.items + i;
@@ -837,6 +833,12 @@ static int rm(int argc, const char **argv)
833
}
834
string_list_clear(&skipped, 0);
835
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
+
842
return result;
843
}
844