Hash :
82368b1b
Author :
Date :
2017-05-12T10:04:42
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
#include "clar_libgit2.h"
#include "index.h"
static git_repository *g_repo = NULL;
void test_index_version__cleanup(void)
{
cl_git_sandbox_cleanup();
g_repo = NULL;
}
void test_index_version__can_read_v4(void)
{
const char *paths[] = {
"file.tx", "file.txt", "file.txz", "foo", "zzz",
};
git_index *index;
size_t i;
g_repo = cl_git_sandbox_init("indexv4");
cl_git_pass(git_repository_index(&index, g_repo));
cl_assert_equal_sz(git_index_entrycount(index), 5);
for (i = 0; i < ARRAY_SIZE(paths); i++) {
const git_index_entry *entry =
git_index_get_bypath(index, paths[i], GIT_INDEX_STAGE_NORMAL);
cl_assert(entry != NULL);
}
git_index_free(index);
}
void test_index_version__can_write_v4(void)
{
git_index *index;
const git_index_entry *entry;
g_repo = cl_git_sandbox_init("filemodes");
cl_git_pass(git_repository_index(&index, g_repo));
cl_assert(index->on_disk);
cl_assert(git_index_version(index) == 2);
cl_assert(git_index_entrycount(index) == 6);
cl_git_pass(git_index_set_version(index, 4));
cl_git_pass(git_index_write(index));
git_index_free(index);
cl_git_pass(git_repository_index(&index, g_repo));
cl_assert(git_index_version(index) == 4);
entry = git_index_get_bypath(index, "exec_off", 0);
cl_assert(entry);
entry = git_index_get_bypath(index, "exec_off2on_staged", 0);
cl_assert(entry);
entry = git_index_get_bypath(index, "exec_on", 0);
cl_assert(entry);
git_index_free(index);
}