summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-11 07:47:17 +0200
committerGitHub <noreply@github.com>2019-10-11 07:47:17 +0200
commitef5a3851fdece852569ffebf3537883223744a7a (patch)
tree00cdd8b6c711d8fa309b7858d5cdc769d0d59b80 /tests
parent1f9b4970c5227909aedd79249eae16585712343f (diff)
parent3335a0346a409695ec5ab43448604a51e45a2d08 (diff)
downloadlibgit2-ef5a3851fdece852569ffebf3537883223744a7a.tar.gz
Merge pull request #5257 from henkesn/master
Fix file locking on POSIX OS
Diffstat (limited to 'tests')
-rw-r--r--tests/refs/transactions.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/refs/transactions.c b/tests/refs/transactions.c
index 39ea1cae5..d4ddf459f 100644
--- a/tests/refs/transactions.c
+++ b/tests/refs/transactions.c
@@ -108,3 +108,24 @@ void test_refs_transactions__unlocked_set(void)
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));
}
+
+void test_refs_transactions__error_on_locking_locked_ref(void)
+{
+ git_oid id;
+ git_transaction *g_tx_with_lock;
+ git_repository *g_repo_with_locking_tx;
+ const char *g_repo_path = git_repository_path(g_repo);
+
+ /* prepare a separate transaction in another instance of testrepo and lock master */
+ cl_git_pass(git_repository_open(&g_repo_with_locking_tx, g_repo_path));
+ cl_git_pass(git_transaction_new(&g_tx_with_lock, g_repo_with_locking_tx));
+ cl_git_pass(git_transaction_lock_ref(g_tx_with_lock, "refs/heads/master"));
+
+ /* lock reference for set_target */
+ cl_git_pass(git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
+ cl_git_fail_with(GIT_ELOCKED, git_transaction_lock_ref(g_tx, "refs/heads/master"));
+ cl_git_fail_with(GIT_ENOTFOUND, git_transaction_set_target(g_tx, "refs/heads/master", &id, NULL, NULL));
+
+ git_transaction_free(g_tx_with_lock);
+ git_repository_free(g_repo_with_locking_tx);
+}