Skip to content

Commit

Permalink
remote rm: delete remote configuration as the last
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Lindström authored and Junio C Hamano committed May 23, 2014
1 parent 4a28f16 commit b07bdd3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b07bdd3

Please sign in to comment.