All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Jens Lindström" <jl@opera.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/3] remote rm: delete remote configuration as the last
Date: Fri, 23 May 2014 11:55:53 -0700	[thread overview]
Message-ID: <xmqqa9a8jpdy.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <537F22DB.7070102@opera.com> ("Jens Lindström"'s message of "Fri, 23 May 2014 12:28:43 +0200")

Jens Lindström <jl@opera.com> writes:

> 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>

I think this is a good change, regardless of the "calling delete-ref
millions of times, each time rewriting the whole packed-ref file, is
inefficient" issue.

I wonder if the new "if (!result)" block wants to have its own else
clause to let the users know that the definition of the remote was
still left intact under such an unusual condition where ref deletion
somehow fails, but it would be OK as the users have presumably seen
error messages and understand that removal did not happen.

Will queue.  Thanks.

> ---
>  builtin/remote.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/remote.c b/builtin/remote.c
> index b3ab4cf..84802cd 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;
>  }

  reply	other threads:[~2014-05-23 18:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 10:34 [PATCH 0/2] remote: optimize rm/prune ref deletion Jens Lindström
2014-05-20 10:39 ` [PATCH 1/2] remote: defer repacking packed-refs when deleting refs Jens Lindström
2014-05-20 19:30   ` Junio C Hamano
2014-05-20 20:29     ` Junio C Hamano
2014-05-23 10:03       ` Jens Lindström
2014-05-23 17:09         ` Junio C Hamano
2014-05-24  7:54           ` Jens Lindström
2014-05-27 16:55             ` Junio C Hamano
2014-05-20 10:41 ` [PATCH 2/2] remote prune: optimize "dangling symref" check/warning Jens Lindström
2014-05-23 10:26 ` [PATCH v2 0/3] remote: optimize rm/prune ref deletion Jens Lindström
2014-05-23 10:28   ` [PATCH v2 1/3] remote rm: delete remote configuration as the last Jens Lindström
2014-05-23 18:55     ` Junio C Hamano [this message]
2014-05-23 10:29   ` [PATCH v2 2/3] remote: repack packed-refs once when deleting multiple refs Jens Lindström
2014-05-23 19:11     ` Junio C Hamano
2014-05-23 19:25       ` Junio C Hamano
2014-05-23 10:30   ` [PATCH v2 3/3] remote prune: optimize "dangling symref" check/warning Jens Lindström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa9a8jpdy.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jl@opera.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.