Skip to content

Commit 1a89900

Browse files
committed
tests: index::version: write v4 index: re-open repo to read written v4 index
The `git_index_free()` merely decrement the reference counter from 2 to 1, and does not "free" the index. Thus, the following `git_repository_index()` merely increase the counter to 2, instead of read index from disk. The written index is not read and parsed, which makes this test case effectively becomes a no-op.
1 parent 8c96d56 commit 1a89900

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/index/version.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void test_index_version__can_write_v4(void)
4343
"xz",
4444
"xyzzyx"
4545
};
46+
git_repository *repo;
4647
git_index_entry entry;
4748
git_index *index;
4849
size_t i;
@@ -63,7 +64,8 @@ void test_index_version__can_write_v4(void)
6364
cl_git_pass(git_index_write(index));
6465
git_index_free(index);
6566

66-
cl_git_pass(git_repository_index(&index, g_repo));
67+
cl_git_pass(git_repository_open(&repo, git_repository_path(g_repo)));
68+
cl_git_pass(git_repository_index(&index, repo));
6769
cl_assert(git_index_version(index) == 4);
6870

6971
for (i = 0; i < ARRAY_SIZE(paths); i++) {
@@ -74,6 +76,7 @@ void test_index_version__can_write_v4(void)
7476
}
7577

7678
git_index_free(index);
79+
git_repository_free(repo);
7780
}
7881

7982
void test_index_version__v4_uses_path_compression(void)

0 commit comments

Comments
 (0)