@@ -20,7 +20,7 @@ void test_index_add__cleanup(void)
2020 cl_git_sandbox_cleanup ();
2121 g_repo = NULL ;
2222
23- cl_git_pass (git_libgit2_opts (GIT_OPT_ENABLE_STRICT_OBJECT_CREATION , 0 ));
23+ cl_git_pass (git_libgit2_opts (GIT_OPT_ENABLE_STRICT_OBJECT_CREATION , 1 ));
2424}
2525
2626static void test_add_entry (
@@ -42,7 +42,7 @@ static void test_add_entry(
4242void test_index_add__invalid_entries_succeeds_by_default (void )
4343{
4444 /*
45- * Ensure that there is no validation on ids by default
45+ * Ensure that there is validation on object ids by default
4646 */
4747
4848 /* ensure that we can add some actually good entries */
@@ -51,34 +51,34 @@ void test_index_add__invalid_entries_succeeds_by_default(void)
5151 test_add_entry (true, valid_blob_id , GIT_FILEMODE_LINK );
5252
5353 /* test that we fail to add some invalid (missing) blobs and trees */
54- test_add_entry (true , invalid_id , GIT_FILEMODE_BLOB );
55- test_add_entry (true , invalid_id , GIT_FILEMODE_BLOB_EXECUTABLE );
56- test_add_entry (true , invalid_id , GIT_FILEMODE_LINK );
54+ test_add_entry (false , invalid_id , GIT_FILEMODE_BLOB );
55+ test_add_entry (false , invalid_id , GIT_FILEMODE_BLOB_EXECUTABLE );
56+ test_add_entry (false , invalid_id , GIT_FILEMODE_LINK );
5757
5858 /* test that we validate the types of objects */
59- test_add_entry (true , valid_commit_id , GIT_FILEMODE_BLOB );
60- test_add_entry (true , valid_tree_id , GIT_FILEMODE_BLOB_EXECUTABLE );
61- test_add_entry (true , valid_commit_id , GIT_FILEMODE_LINK );
59+ test_add_entry (false , valid_commit_id , GIT_FILEMODE_BLOB );
60+ test_add_entry (false , valid_tree_id , GIT_FILEMODE_BLOB_EXECUTABLE );
61+ test_add_entry (false , valid_commit_id , GIT_FILEMODE_LINK );
6262
6363 /*
64- * Ensure that strict object references will fail the `index_add`
64+ * Ensure that there we can disable validation
6565 */
6666
67- cl_git_pass (git_libgit2_opts (GIT_OPT_ENABLE_STRICT_OBJECT_CREATION , 1 ));
67+ cl_git_pass (git_libgit2_opts (GIT_OPT_ENABLE_STRICT_OBJECT_CREATION , 0 ));
6868
6969 /* ensure that we can add some actually good entries */
7070 test_add_entry (true, valid_blob_id , GIT_FILEMODE_BLOB );
7171 test_add_entry (true, valid_blob_id , GIT_FILEMODE_BLOB_EXECUTABLE );
7272 test_add_entry (true, valid_blob_id , GIT_FILEMODE_LINK );
7373
74- /* test that we fail to add some invalid (missing) blobs and trees */
75- test_add_entry (false , invalid_id , GIT_FILEMODE_BLOB );
76- test_add_entry (false , invalid_id , GIT_FILEMODE_BLOB_EXECUTABLE );
77- test_add_entry (false , invalid_id , GIT_FILEMODE_LINK );
74+ /* test that we can now add some invalid (missing) blobs and trees */
75+ test_add_entry (true , invalid_id , GIT_FILEMODE_BLOB );
76+ test_add_entry (true , invalid_id , GIT_FILEMODE_BLOB_EXECUTABLE );
77+ test_add_entry (true , invalid_id , GIT_FILEMODE_LINK );
7878
79- /* test that we validate the types of objects */
80- test_add_entry (false , valid_commit_id , GIT_FILEMODE_BLOB );
81- test_add_entry (false , valid_tree_id , GIT_FILEMODE_BLOB_EXECUTABLE );
82- test_add_entry (false , valid_commit_id , GIT_FILEMODE_LINK );
79+ /* test that we do not validate the types of objects */
80+ test_add_entry (true , valid_commit_id , GIT_FILEMODE_BLOB );
81+ test_add_entry (true , valid_tree_id , GIT_FILEMODE_BLOB_EXECUTABLE );
82+ test_add_entry (true , valid_commit_id , GIT_FILEMODE_LINK );
8383}
8484
0 commit comments