summaryrefslogtreecommitdiff
path: root/tests-clar/index
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-08-19 10:30:44 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2013-08-19 10:30:44 +0200
commit3d2768747548ec24b58ebdaa012a6b757e65f5a0 (patch)
treeac7653603379d3b1bc406becb247105967264221 /tests-clar/index
parent8f81ea45ca107c992313f76ee73316f16751e64e (diff)
downloadlibgit2-3d2768747548ec24b58ebdaa012a6b757e65f5a0.tar.gz
index: report when it's locked
Report the index being locked with its own error code in order to be able to differentiate, as a locked index is typically the result of a crashed process or concurrent access, both of which often require user intervention to fix.
Diffstat (limited to 'tests-clar/index')
-rw-r--r--tests-clar/index/tests.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 1bc5e6a07..9090d4d8a 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -459,3 +459,28 @@ void test_index_tests__preserves_case(void)
git_repository_free(repo);
}
+void test_index_tests__elocked(void)
+{
+ git_repository *repo;
+ git_index *index;
+ git_filebuf file = GIT_FILEBUF_INIT;
+ const git_error *err;
+ int error;
+
+ cl_set_cleanup(&cleanup_myrepo, NULL);
+
+ cl_git_pass(git_repository_init(&repo, "./myrepo", 0));
+ cl_git_pass(git_repository_index(&index, repo));
+
+ /* Lock the index file so we fail to lock it */
+ cl_git_pass(git_filebuf_open(&file, index->index_file_path, 0));
+ error = git_index_write(index);
+ cl_assert_equal_i(GIT_ELOCKED, error);
+
+ err = giterr_last();
+ cl_assert_equal_i(err->klass, GITERR_INDEX);
+
+ git_filebuf_cleanup(&file);
+ git_index_free(index);
+ git_repository_free(repo);
+}