From 34b8eafcaea7fc12f91691195c9b7289038c4abb Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 4 Oct 2013 11:36:40 +0200 Subject: Tabify indentations --- tests-clar/index/tests.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests-clar/index/tests.c') diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c index 9090d4d8a..0528eb110 100644 --- a/tests-clar/index/tests.c +++ b/tests-clar/index/tests.c @@ -99,11 +99,11 @@ void test_index_tests__default_test_index(void) entries = (git_index_entry **)index->entries.contents; for (i = 0; i < ARRAY_SIZE(test_entries); ++i) { - git_index_entry *e = entries[test_entries[i].index]; + git_index_entry *e = entries[test_entries[i].index]; - cl_assert_equal_s(e->path, test_entries[i].path); - cl_assert(e->mtime.seconds == test_entries[i].mtime); - cl_assert(e->file_size == test_entries[i].file_size); + cl_assert_equal_s(e->path, test_entries[i].path); + cl_assert(e->mtime.seconds == test_entries[i].mtime); + cl_assert(e->file_size == test_entries[i].file_size); } git_index_free(index); @@ -131,10 +131,10 @@ void test_index_tests__find_in_existing(void) cl_git_pass(git_index_open(&index, TEST_INDEX_PATH)); for (i = 0; i < ARRAY_SIZE(test_entries); ++i) { - size_t idx; + size_t idx; - cl_assert(!git_index_find(&idx, index, test_entries[i].path)); - cl_assert(idx == test_entries[i].index); + cl_assert(!git_index_find(&idx, index, test_entries[i].path)); + cl_assert(idx == test_entries[i].index); } git_index_free(index); @@ -148,7 +148,7 @@ void test_index_tests__find_in_empty(void) cl_git_pass(git_index_open(&index, "fake-index")); for (i = 0; i < ARRAY_SIZE(test_entries); ++i) { - cl_assert(GIT_ENOTFOUND == git_index_find(NULL, index, test_entries[i].path)); + cl_assert(GIT_ENOTFOUND == git_index_find(NULL, index, test_entries[i].path)); } git_index_free(index); -- cgit v1.2.3 From da7b78fa446b31e7e197d51129d9bd005acc69da Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 4 Oct 2013 14:03:12 +0200 Subject: index: Make _read() cope with index file creation --- tests-clar/index/tests.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests-clar/index/tests.c') diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c index 0528eb110..009d393d7 100644 --- a/tests-clar/index/tests.c +++ b/tests-clar/index/tests.c @@ -484,3 +484,53 @@ void test_index_tests__elocked(void) git_index_free(index); git_repository_free(repo); } + +void test_index_tests__reload_from_disk(void) +{ + git_repository *repo; + git_index *read_index; + git_index *write_index; + + cl_set_cleanup(&cleanup_myrepo, NULL); + + cl_git_pass(git_futils_mkdir("./myrepo", NULL, 0777, GIT_MKDIR_PATH)); + cl_git_mkfile("./myrepo/a.txt", "a\n"); + cl_git_mkfile("./myrepo/b.txt", "b\n"); + + cl_git_pass(git_repository_init(&repo, "./myrepo", 0)); + cl_git_pass(git_repository_index(&write_index, repo)); + cl_assert_equal_i(false, write_index->on_disk); + + cl_git_pass(git_index_open(&read_index, write_index->index_file_path)); + cl_assert_equal_i(false, read_index->on_disk); + + /* Stage two new files agaisnt the write_index */ + cl_git_pass(git_index_add_bypath(write_index, "a.txt")); + cl_git_pass(git_index_add_bypath(write_index, "b.txt")); + + cl_assert_equal_sz(2, git_index_entrycount(write_index)); + + /* Persist the index changes to disk */ + cl_git_pass(git_index_write(write_index)); + cl_assert_equal_i(true, write_index->on_disk); + + /* Sync the changes back into the read_index */ + cl_assert_equal_sz(0, git_index_entrycount(read_index)); + + cl_git_pass(git_index_read(read_index)); + cl_assert_equal_i(true, read_index->on_disk); + + cl_assert_equal_sz(2, git_index_entrycount(read_index)); + + /* Remove the index file from the filesystem */ + cl_git_pass(p_unlink(write_index->index_file_path)); + + /* Sync the changes back into the read_index */ + cl_git_pass(git_index_read(read_index)); + cl_assert_equal_i(false, read_index->on_disk); + cl_assert_equal_sz(0, git_index_entrycount(read_index)); + + git_index_free(read_index); + git_index_free(write_index); + git_repository_free(repo); +} -- cgit v1.2.3