index::addall tests: write the index When running `git_index_add_all`, we should write the index to disk so that we can re-read it safely during status.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
diff --git a/tests/index/addall.c b/tests/index/addall.c
index 7b7a178..49e5079 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -173,6 +173,7 @@ void test_index_addall__repo_lifecycle(void)
paths.count = 1;
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.bar", true);
check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0);
@@ -190,6 +191,7 @@ void test_index_addall__repo_lifecycle(void)
check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0);
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.zzz", true);
check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0);
@@ -212,17 +214,20 @@ void test_index_addall__repo_lifecycle(void)
/* attempt to add an ignored file - does nothing */
strs[0] = "file.foo";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
/* add with check - should generate error */
error = git_index_add_all(
index, &paths, GIT_INDEX_ADD_CHECK_PATHSPEC, NULL, NULL);
cl_assert_equal_i(GIT_EINVALIDSPEC, error);
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
/* add with force - should allow */
cl_git_pass(git_index_add_all(
index, &paths, GIT_INDEX_ADD_FORCE, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.foo", true);
check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0);
@@ -232,6 +237,7 @@ void test_index_addall__repo_lifecycle(void)
check_status(g_repo, 1, 0, 0, 3, 0, 1, 0, 0);
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.foo", true);
check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0);
@@ -265,6 +271,7 @@ void test_index_addall__repo_lifecycle(void)
strs[0] = "*";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 3, 1, 0, 0, 0, 0, 0, 0);
/* must be able to remove at any position while still updating other files */
@@ -294,6 +301,7 @@ void test_index_addall__files_in_folders(void)
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.bar", true);
check_status(g_repo, 2, 0, 0, 0, 0, 0, 1, 0);
@@ -302,6 +310,7 @@ void test_index_addall__files_in_folders(void)
check_status(g_repo, 2, 0, 0, 1, 0, 0, 1, 0);
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 3, 0, 0, 0, 0, 0, 1, 0);
git_index_free(index);
@@ -319,6 +328,7 @@ void test_index_addall__hidden_files(void)
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.bar", true);
check_status(g_repo, 2, 0, 0, 0, 0, 0, 1, 0);
@@ -335,6 +345,7 @@ void test_index_addall__hidden_files(void)
check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0);
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.bar", true);
check_status(g_repo, 5, 0, 0, 0, 0, 0, 1, 0);
@@ -373,6 +384,7 @@ void test_index_addall__callback_filtering(void)
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_prefix, "file."));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/file.bar", true);
check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0);
@@ -386,11 +398,13 @@ void test_index_addall__callback_filtering(void)
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_prefix, "other"));
+ cl_git_pass(git_index_write(index));
check_stat_data(index, TEST_DIR "/other.zzz", true);
check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0);
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz"));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 4, 0, 0, 1, 0, 0, 1, 0);
cl_git_pass(
@@ -407,6 +421,7 @@ void test_index_addall__callback_filtering(void)
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz"));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 5, 0, 0, 0, 0, 0, 1, 0);
cl_must_pass(p_unlink(TEST_DIR "/file.zzz"));
@@ -446,6 +461,7 @@ void test_index_addall__adds_conflicts(void)
check_status(g_repo, 0, 1, 2, 0, 0, 0, 0, 1);
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 0, 1, 3, 0, 0, 0, 0, 0);
git_annotated_commit_free(annotated);
@@ -473,6 +489,7 @@ void test_index_addall__removes_deleted_conflicted_files(void)
cl_git_rmfile("merge-resolve/conflicting.txt");
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ cl_git_pass(git_index_write(index));
check_status(g_repo, 0, 2, 2, 0, 0, 0, 0, 0);
git_annotated_commit_free(annotated);