Re: [PATCH v11 14/41] refs.c: update ref_transaction_delete to check for error and return status
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- May 28, 2014, 18:42 UTC
- Message-ID
- <20140528184234.GS12314@google.com>
- In-Reply-To
- <1401222360-21175-15-git-send-email-sahlberg@google.com>
Ronnie Sahlberg wrote:
Show 6 quoted lines
> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> > --- > builtin/update-ref.c | 5 +++-- > refs.c | 16 +++++++++++----- > refs.h | 12 ++++++++---- > 3 files changed, 22 insertions(+), 11 deletions(-)
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
[...]
Show 26 quoted lines
> +++ b/refs.c
> @@ -3417,19 +3417,25 @@ int ref_transaction_create(struct ref_transaction *transaction,
> return 0;
> }
>
> -void ref_transaction_delete(struct ref_transaction *transaction,
> - const char *refname,
> - const unsigned char *old_sha1,
> - int flags, int have_old)
> +int ref_transaction_delete(struct ref_transaction *transaction,
> + const char *refname,
> + const unsigned char *old_sha1,
> + int flags, int have_old,
> + struct strbuf *err)
> {
> - struct ref_update *update = add_update(transaction, refname);
> + struct ref_update *update;
>
> + if (have_old && !old_sha1)
> + die("BUG: have_old is true but old_sha1 is NULL");
> +
> + update = add_update(transaction, refname);
> update->flags = flags;
> update->have_old = have_old;
> if (have_old) {
> assert(!is_null_sha1(old_sha1));Could combine this into the 'if (have_old &&' check.
Thanks, Jonathan