refs.c: change ref_transaction_create to do error checking and return status
Do basic error checking in ref_transaction_create() and make it return non-zero on error. Update all callers to check the result of ref_transaction_create(). There are currently no conditions in _create that will return error but there will be in the future. Add an err argument that will be updated on failure. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8e34800e5b
commit
b416af5bcd
18
refs.c
18
refs.c
@ -3449,18 +3449,24 @@ int ref_transaction_update(struct ref_transaction *transaction,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ref_transaction_create(struct ref_transaction *transaction,
|
||||
const char *refname,
|
||||
const unsigned char *new_sha1,
|
||||
int flags)
|
||||
int ref_transaction_create(struct ref_transaction *transaction,
|
||||
const char *refname,
|
||||
const unsigned char *new_sha1,
|
||||
int flags,
|
||||
struct strbuf *err)
|
||||
{
|
||||
struct ref_update *update = add_update(transaction, refname);
|
||||
struct ref_update *update;
|
||||
|
||||
if (!new_sha1 || is_null_sha1(new_sha1))
|
||||
die("BUG: create ref with null new_sha1");
|
||||
|
||||
update = add_update(transaction, refname);
|
||||
|
||||
assert(!is_null_sha1(new_sha1));
|
||||
hashcpy(update->new_sha1, new_sha1);
|
||||
hashclr(update->old_sha1);
|
||||
update->flags = flags;
|
||||
update->have_old = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ref_transaction_delete(struct ref_transaction *transaction,
|
||||
|
||||
Reference in New Issue
Block a user