Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-11-01 01:36:52 +0400
committerRussell Belfer <rb@github.com>2013-11-01 21:20:51 +0400
commit4bf630b6baf342fa929a8f7e4e6643197b74216f (patch)
tree95778a5807b4043202eaea18a266a264e611649c /tests-clar/index/tests.c
parent3940310e29363978ccdc1f3b557bc6f48ebae8f0 (diff)
Make diff and status perform soft index reload
This changes `git_index_read` to have two modes - a hard index reload that always resets the index to match the on-disk data (which was the old behavior) and a soft index reload that uses the timestamp / file size information and only replaces the index data if the file on disk has been modified. This then updates the git_status code to do a soft reload unless the new GIT_STATUS_OPT_NO_REFRESH flag is passed in. This also changes the behavior of the git_diff functions that use the index so that when an index is not explicitly passed in (i.e. when the functions call git_repository_index for you), they will also do a soft reload for you. This intentionally breaks the file signature of git_index_read because there has been some confusion about the behavior previously and it seems like all existing uses of the API should probably be examined to select the desired behavior.
Diffstat (limited to 'tests-clar/index/tests.c')
-rw-r--r--tests-clar/index/tests.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 009d393d7..f538bc278 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -349,14 +349,14 @@ void test_index_tests__remove_entry(void)
cl_git_pass(git_index_add_bypath(index, "hello"));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_index_read(index)); /* reload */
+ cl_git_pass(git_index_read(index, false)); /* reload */
cl_assert(git_index_entrycount(index) == 1);
cl_assert(git_index_get_bypath(index, "hello", 0) != NULL);
cl_git_pass(git_index_remove(index, "hello", 0));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_index_read(index)); /* reload */
+ cl_git_pass(git_index_read(index, false)); /* reload */
cl_assert(git_index_entrycount(index) == 0);
cl_assert(git_index_get_bypath(index, "hello", 0) == NULL);
@@ -388,7 +388,7 @@ void test_index_tests__remove_directory(void)
cl_git_pass(git_index_add_bypath(index, "b.txt"));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_index_read(index)); /* reload */
+ cl_git_pass(git_index_read(index, false)); /* reload */
cl_assert_equal_i(4, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) != NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) != NULL);
@@ -397,7 +397,7 @@ void test_index_tests__remove_directory(void)
cl_git_pass(git_index_remove(index, "a/1.txt", 0));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_index_read(index)); /* reload */
+ cl_git_pass(git_index_read(index, false)); /* reload */
cl_assert_equal_i(3, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) == NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) != NULL);
@@ -406,7 +406,7 @@ void test_index_tests__remove_directory(void)
cl_git_pass(git_index_remove_directory(index, "a", 0));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_index_read(index)); /* reload */
+ cl_git_pass(git_index_read(index, false)); /* reload */
cl_assert_equal_i(1, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) == NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) == NULL);
@@ -517,7 +517,7 @@ void test_index_tests__reload_from_disk(void)
/* 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_git_pass(git_index_read(read_index, false));
cl_assert_equal_i(true, read_index->on_disk);
cl_assert_equal_sz(2, git_index_entrycount(read_index));
@@ -526,7 +526,7 @@ void test_index_tests__reload_from_disk(void)
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_git_pass(git_index_read(read_index, false));
cl_assert_equal_i(false, read_index->on_disk);
cl_assert_equal_sz(0, git_index_entrycount(read_index));