summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJens Lindström <jl@opera.com>2014-05-23 12:28:43 +0200
committerJunio C Hamano <gitster@pobox.com>2014-05-23 11:56:15 -0700
commitb07bdd3472886cbdd412ee3e7489273522c43133 (patch)
tree4b32588dae82bbe263fa3901b3a731aee503711f /builtin
parent4a28f169ad29ba452e0e7bea2583914c10c58322 (diff)
downloadgit-b07bdd3472886cbdd412ee3e7489273522c43133.tar.gz
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/remote.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index b3ab4cf8f6..84802cd0a1 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -789,10 +789,6 @@ static int rm(int argc, const char **argv)
known_remotes.to_delete = remote;
for_each_remote(add_known_remote, &known_remotes);
- strbuf_addf(&buf, "remote.%s", remote->name);
- if (git_config_rename_section(buf.buf, NULL) < 1)
- return error(_("Could not remove config section '%s'"), buf.buf);
-
read_branches();
for (i = 0; i < branch_list.nr; i++) {
struct string_list_item *item = branch_list.items + i;
@@ -837,6 +833,12 @@ static int rm(int argc, const char **argv)
}
string_list_clear(&skipped, 0);
+ if (!result) {
+ strbuf_addf(&buf, "remote.%s", remote->name);
+ if (git_config_rename_section(buf.buf, NULL) < 1)
+ return error(_("Could not remove config section '%s'"), buf.buf);
+ }
+
return result;
}