Subject: Re: [PATCH v7 4/6] refs: add TRANSACTION_CREATE_EXISTS error

From: Phillip Wood <[email-masked]>
Date: Mon, 14 Oct 2024 09:48:10 +0100

Hi Bence

On 13/10/2024 21:52, Bence Ferdinandy wrote:
> On Sun Oct 13, 2024 at 16:03, Phillip Wood <[email-masked]> wrote:

>>> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
>>> index 3c96fbf66f..ebf8e57fbc 100644
>>> --- a/refs/reftable-backend.c
>>> +++ b/refs/reftable-backend.c
>>> @@ -1206,10 +1206,13 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
>>>    				goto done;
>>>    			}
>>>    		} else if ((u->flags & REF_HAVE_OLD) && !oideq(&current_oid, &u->old_oid)) {
>>> -			if (is_null_oid(&u->old_oid))
>>> +			ret = TRANSACTION_NAME_CONFLICT;
>>> +			if (is_null_oid(&u->old_oid)) {
>>>    				strbuf_addf(err, _("cannot lock ref '%s': "
>>>    						   "reference already exists"),
>>>    					    ref_update_original_update_refname(u));
>>> +				ret = TRANSACTION_CREATE_EXISTS;
>>> +			}
>>>    			else if (is_null_oid(&current_oid))
>>>    				strbuf_addf(err, _("cannot lock ref '%s': "
>>>    						   "reference is missing but expected %s"),
>>> @@ -1221,7 +1224,6 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
>>>    					    ref_update_original_update_refname(u),
>>>    					    oid_to_hex(&current_oid),
>>>    					    oid_to_hex(&u->old_oid));
>>> -			ret = -1;
>>>    			goto done;
>>>    		}
>>>    
> 
> This originally returned -1, and it still returns that if it doesn't return -2,
> I just used the named variable instead of the integer itself. It might still be
> that this should be -3 GENERIC_ERROR, but if that is the case I think fixing
> that should be a different patch? I didn't check if changing that -1 to
> something else breaks anything or not.

Oh sorry I was confused and thought TRANSACTION_GENERIC_ERROR was -1.

Best Wishes

Phillip

> Best,
> Bence