vendor/libgit2/src/transaction.c in rugged-0.27.10.1 vs vendor/libgit2/src/transaction.c in rugged-0.28.0

- old
+ new

@@ -28,11 +28,11 @@ typedef struct { const char *name; void *payload; - git_ref_t ref_type; + git_reference_t ref_type; union { git_oid id; char *symbolic; } target; git_reflog *reflog; @@ -58,11 +58,11 @@ { git_transaction *tx; assert(out && cfg); tx = git__calloc(1, sizeof(git_transaction)); - GITERR_CHECK_ALLOC(tx); + GIT_ERROR_CHECK_ALLOC(tx); tx->type = TRANSACTION_CONFIG; tx->cfg = cfg; *out = tx; return 0; @@ -109,20 +109,20 @@ transaction_node *node; assert(tx && refname); node = git_pool_mallocz(&tx->pool, sizeof(transaction_node)); - GITERR_CHECK_ALLOC(node); + GIT_ERROR_CHECK_ALLOC(node); node->name = git_pool_strdup(&tx->pool, refname); - GITERR_CHECK_ALLOC(node->name); + GIT_ERROR_CHECK_ALLOC(node->name); if ((error = git_refdb_lock(&node->payload, tx->db, refname)) < 0) return error; git_strmap_insert(tx->locks, node->name, node, &error); - if (error < 0) + if (error < 0) goto cleanup; return 0; cleanup: @@ -131,16 +131,16 @@ return error; } static int find_locked(transaction_node **out, git_transaction *tx, const char *refname) { - git_strmap_iter pos; transaction_node *node; + size_t pos; pos = git_strmap_lookup_index(tx->locks, refname); if (!git_strmap_valid_index(tx->locks, pos)) { - giterr_set(GITERR_REFERENCE, "the specified reference is not locked"); + git_error_set(GIT_ERROR_REFERENCE, "the specified reference is not locked"); return GIT_ENOTFOUND; } node = git_strmap_value_at(tx->locks, pos); @@ -167,11 +167,11 @@ return error; } if (msg) { node->message = git_pool_strdup(&tx->pool, msg); - GITERR_CHECK_ALLOC(node->message); + GIT_ERROR_CHECK_ALLOC(node->message); } return 0; } @@ -187,11 +187,11 @@ if ((error = copy_common(node, tx, sig, msg)) < 0) return error; git_oid_cpy(&node->target.id, target); - node->ref_type = GIT_REF_OID; + node->ref_type = GIT_REFERENCE_DIRECT; return 0; } int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg) @@ -206,12 +206,12 @@ if ((error = copy_common(node, tx, sig, msg)) < 0) return error; node->target.symbolic = git_pool_strdup(&tx->pool, target); - GITERR_CHECK_ALLOC(node->target.symbolic); - node->ref_type = GIT_REF_SYMBOLIC; + GIT_ERROR_CHECK_ALLOC(node->target.symbolic); + node->ref_type = GIT_REFERENCE_SYMBOLIC; return 0; } int git_transaction_remove(git_transaction *tx, const char *refname) @@ -221,11 +221,11 @@ if ((error = find_locked(&node, tx, refname)) < 0) return error; node->remove = true; - node->ref_type = GIT_REF_OID; /* the id will be ignored */ + node->ref_type = GIT_REFERENCE_DIRECT; /* the id will be ignored */ return 0; } static int dup_reflog(git_reflog **out, const git_reflog *in, git_pool *pool) @@ -233,22 +233,22 @@ git_reflog *reflog; git_reflog_entry *entries; size_t len, i; reflog = git_pool_mallocz(pool, sizeof(git_reflog)); - GITERR_CHECK_ALLOC(reflog); + GIT_ERROR_CHECK_ALLOC(reflog); reflog->ref_name = git_pool_strdup(pool, in->ref_name); - GITERR_CHECK_ALLOC(reflog->ref_name); + GIT_ERROR_CHECK_ALLOC(reflog->ref_name); len = in->entries.length; reflog->entries.length = len; reflog->entries.contents = git_pool_mallocz(pool, len * sizeof(void *)); - GITERR_CHECK_ALLOC(reflog->entries.contents); + GIT_ERROR_CHECK_ALLOC(reflog->entries.contents); entries = git_pool_mallocz(pool, len * sizeof(git_reflog_entry)); - GITERR_CHECK_ALLOC(entries); + GIT_ERROR_CHECK_ALLOC(entries); for (i = 0; i < len; i++) { const git_reflog_entry *src; git_reflog_entry *tgt; @@ -258,11 +258,11 @@ src = git_vector_get(&in->entries, i); git_oid_cpy(&tgt->oid_old, &src->oid_old); git_oid_cpy(&tgt->oid_cur, &src->oid_cur); tgt->msg = git_pool_strdup(pool, src->msg); - GITERR_CHECK_ALLOC(tgt->msg); + GIT_ERROR_CHECK_ALLOC(tgt->msg); if (git_signature__pdup(&tgt->committer, src->committer, pool) < 0) return -1; } @@ -290,26 +290,26 @@ static int update_target(git_refdb *db, transaction_node *node) { git_reference *ref; int error, update_reflog; - if (node->ref_type == GIT_REF_OID) { + if (node->ref_type == GIT_REFERENCE_DIRECT) { ref = git_reference__alloc(node->name, &node->target.id, NULL); - } else if (node->ref_type == GIT_REF_SYMBOLIC) { + } else if (node->ref_type == GIT_REFERENCE_SYMBOLIC) { ref = git_reference__alloc_symbolic(node->name, node->target.symbolic); } else { abort(); } - GITERR_CHECK_ALLOC(ref); + GIT_ERROR_CHECK_ALLOC(ref); update_reflog = node->reflog == NULL; if (node->remove) { error = git_refdb_unlock(db, node->payload, 2, false, ref, NULL, NULL); - } else if (node->ref_type == GIT_REF_OID) { + } else if (node->ref_type == GIT_REFERENCE_DIRECT) { error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); - } else if (node->ref_type == GIT_REF_SYMBOLIC) { + } else if (node->ref_type == GIT_REFERENCE_SYMBOLIC) { error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); } else { abort(); } @@ -337,10 +337,10 @@ if (node->reflog) { if ((error = tx->db->backend->reflog_write(tx->db->backend, node->reflog)) < 0) return error; } - if (node->ref_type != GIT_REF_INVALID) { + if (node->ref_type != GIT_REFERENCE_INVALID) { if ((error = update_target(tx->db, node)) < 0) return error; } });