mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 22:44:42 +00:00
transaction: rename lock() to lock_ref()
This leaves space for future expansion to locking other resources without having to change the API for references.
This commit is contained in:
parent
274c3fa62e
commit
c327d5db8b
@ -32,7 +32,7 @@ GIT_EXTERN(int) git_transaction_new(git_transaction **out, git_repository *repo)
|
|||||||
* @param refname the reference to lock
|
* @param refname the reference to lock
|
||||||
* @return 0 or an error message
|
* @return 0 or an error message
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_transaction_lock(git_transaction *tx, const char *refname);
|
GIT_EXTERN(int) git_transaction_lock_ref(git_transaction *tx, const char *refname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the target of a reference
|
* Set the target of a reference
|
||||||
|
@ -611,7 +611,7 @@ int git_stash_drop(
|
|||||||
if ((error = git_transaction_new(&tx, repo)) < 0)
|
if ((error = git_transaction_new(&tx, repo)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if ((error = git_transaction_lock(tx, GIT_REFS_STASH_FILE)) < 0)
|
if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
|
if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||||
|
@ -80,7 +80,7 @@ on_error:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_transaction_lock(git_transaction *tx, const char *refname)
|
int git_transaction_lock_ref(git_transaction *tx, const char *refname)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
transaction_node *node;
|
transaction_node *node;
|
||||||
|
@ -23,7 +23,7 @@ void test_refs_transactions__single_ref_oid(void)
|
|||||||
|
|
||||||
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "refs/heads/master"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master"));
|
||||||
cl_git_pass(git_transaction_set_target(g_tx, "refs/heads/master", &id, NULL, NULL));
|
cl_git_pass(git_transaction_set_target(g_tx, "refs/heads/master", &id, NULL, NULL));
|
||||||
cl_git_pass(git_transaction_commit(g_tx));
|
cl_git_pass(git_transaction_commit(g_tx));
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ void test_refs_transactions__single_ref_symbolic(void)
|
|||||||
{
|
{
|
||||||
git_reference *ref;
|
git_reference *ref;
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "HEAD"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "HEAD"));
|
||||||
cl_git_pass(git_transaction_set_symbolic_target(g_tx, "HEAD", "refs/heads/foo", NULL, NULL));
|
cl_git_pass(git_transaction_set_symbolic_target(g_tx, "HEAD", "refs/heads/foo", NULL, NULL));
|
||||||
cl_git_pass(git_transaction_commit(g_tx));
|
cl_git_pass(git_transaction_commit(g_tx));
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ void test_refs_transactions__single_ref_mix_types(void)
|
|||||||
|
|
||||||
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "refs/heads/master"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master"));
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "HEAD"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "HEAD"));
|
||||||
cl_git_pass(git_transaction_set_symbolic_target(g_tx, "refs/heads/master", "refs/heads/foo", NULL, NULL));
|
cl_git_pass(git_transaction_set_symbolic_target(g_tx, "refs/heads/master", "refs/heads/foo", NULL, NULL));
|
||||||
cl_git_pass(git_transaction_set_target(g_tx, "HEAD", &id, NULL, NULL));
|
cl_git_pass(git_transaction_set_target(g_tx, "HEAD", &id, NULL, NULL));
|
||||||
cl_git_pass(git_transaction_commit(g_tx));
|
cl_git_pass(git_transaction_commit(g_tx));
|
||||||
@ -73,7 +73,7 @@ void test_refs_transactions__single_ref_delete(void)
|
|||||||
{
|
{
|
||||||
git_reference *ref;
|
git_reference *ref;
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "refs/heads/master"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master"));
|
||||||
cl_git_pass(git_transaction_remove(g_tx, "refs/heads/master"));
|
cl_git_pass(git_transaction_remove(g_tx, "refs/heads/master"));
|
||||||
cl_git_pass(git_transaction_commit(g_tx));
|
cl_git_pass(git_transaction_commit(g_tx));
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void test_refs_transactions__single_create(void)
|
|||||||
|
|
||||||
cl_git_fail_with(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo, name));
|
cl_git_fail_with(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo, name));
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, name));
|
cl_git_pass(git_transaction_lock_ref(g_tx, name));
|
||||||
|
|
||||||
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
||||||
cl_git_pass(git_transaction_set_target(g_tx, name, &id, NULL, NULL));
|
cl_git_pass(git_transaction_set_target(g_tx, name, &id, NULL, NULL));
|
||||||
@ -103,7 +103,7 @@ void test_refs_transactions__unlocked_set(void)
|
|||||||
{
|
{
|
||||||
git_oid id;
|
git_oid id;
|
||||||
|
|
||||||
cl_git_pass(git_transaction_lock(g_tx, "refs/heads/master"));
|
cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master"));
|
||||||
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
||||||
cl_git_fail_with(GIT_ENOTFOUND, git_transaction_set_target(g_tx, "refs/heads/foo", &id, NULL, NULL));
|
cl_git_fail_with(GIT_ENOTFOUND, git_transaction_set_target(g_tx, "refs/heads/foo", &id, NULL, NULL));
|
||||||
cl_git_pass(git_transaction_commit(g_tx));
|
cl_git_pass(git_transaction_commit(g_tx));
|
||||||
|
Loading…
Reference in New Issue
Block a user