Subject: Re: [PATCH v11 32/41] refs.c: make delete_ref use a transaction

From: Jonathan Nieder <[email-masked]>
Date: Fri, 30 May 2014 10:28:08 -0700

Ronnie Sahlberg wrote:

> Signed-off-by: Ronnie Sahlberg <[email-masked]>
> ---
>  refs.c | 34 +++++++++++++---------------------
>  1 file changed, 13 insertions(+), 21 deletions(-)

Reviewed-by: Jonathan Nieder <[email-masked]>

[...]
> +++ b/refs.c
[...]
> @@ -2542,24 +2537,21 @@ static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
>  
>  int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
>  {
[...]
> +	if (!transaction ||
> +	    ref_transaction_delete(transaction, refname, sha1, delopt,
> +				   sha1 && !is_null_sha1(sha1), &err) ||
> +	    ref_transaction_commit(transaction, NULL, &err)) {
> +		error("%s", err.buf);
> +		ref_transaction_free(transaction);
> +		strbuf_release(&err);
>  		return 1;
> +	}
[...]
> -	ret |= repack_without_ref(lock->ref_name);

The old return value could be 1 or -1 depending on how the deletion
failed.  Now it's consistently 1.

The only callers I see that care are cmd_symbolic_ref and
cmd_update_ref, for which 1 is better (-1 would result in an exit
status of 255, which means something like "died with signal 127").

Thanks,
Jonathan