vendor/libgit2/src/transaction.c in rugged-0.28.3.1 vs vendor/libgit2/src/transaction.c in rugged-0.28.4
- old
+ new
@@ -82,11 +82,11 @@
if (!tx) {
error = -1;
goto on_error;
}
- if ((error = git_strmap_alloc(&tx->locks)) < 0) {
+ if ((error = git_strmap_new(&tx->locks)) < 0) {
error = -1;
goto on_error;
}
if ((error = git_repository_refdb(&tx->db, repo)) < 0)
@@ -117,12 +117,11 @@
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 = git_strmap_set(tx->locks, node->name, node)) < 0)
goto cleanup;
return 0;
cleanup:
@@ -132,20 +131,16 @@
}
static int find_locked(transaction_node **out, git_transaction *tx, const char *refname)
{
transaction_node *node;
- size_t pos;
- pos = git_strmap_lookup_index(tx->locks, refname);
- if (!git_strmap_valid_index(tx->locks, pos)) {
+ if ((node = git_strmap_get(tx->locks, refname)) == NULL) {
git_error_set(GIT_ERROR_REFERENCE, "the specified reference is not locked");
return GIT_ENOTFOUND;
}
- node = git_strmap_value_at(tx->locks, pos);
-
*out = node;
return 0;
}
static int copy_common(transaction_node *node, git_transaction *tx, const git_signature *sig, const char *msg)
@@ -337,10 +332,16 @@
if (node->reflog) {
if ((error = tx->db->backend->reflog_write(tx->db->backend, node->reflog)) < 0)
return error;
}
- if (node->ref_type != GIT_REFERENCE_INVALID) {
+ if (node->ref_type == GIT_REFERENCE_INVALID) {
+ /* ref was locked but not modified */
+ if ((error = git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL)) < 0) {
+ return error;
+ }
+ node->committed = true;
+ } else {
if ((error = update_target(tx->db, node)) < 0)
return error;
}
});