summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-11-16 18:05:46 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-11-16 22:59:01 -0500
commitc30051f0d0fd6ff74d6e2fbe0fc5b0209ecf8b85 (patch)
treeaa8a8d29063c64e8d670f09997f052318b1ececb
parent27bc41cf1798c8937b323a7fe6c7fe459c70f8c1 (diff)
downloadlibgit2-c30051f0d0fd6ff74d6e2fbe0fc5b0209ecf8b85.tar.gz
racy: ensure git_index_read_tree clears uptodate
Ensure that `git_index_read_tree` clears the uptodate bit on files that it modifies.
-rw-r--r--tests/index/racy.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/index/racy.c b/tests/index/racy.c
index fc48f07a8..ce395316f 100644
--- a/tests/index/racy.c
+++ b/tests/index/racy.c
@@ -250,3 +250,31 @@ void test_index_racy__reading_clears_uptodate_bit(void)
git_index_free(index);
}
+
+void test_index_racy__read_tree_clears_uptodate_bit(void)
+{
+ git_index *index;
+ git_tree *tree;
+ const git_index_entry *entry;
+ git_oid id;
+
+ setup_uptodate_files();
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_write_tree_to(&id, index, g_repo));
+ cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
+ cl_git_pass(git_index_read_tree(index, tree));
+
+ /* ensure that no files are uptodate */
+ cl_assert((entry = git_index_get_bypath(index, "A", 0)));
+ cl_assert_equal_i(0, (entry->flags_extended & GIT_IDXENTRY_UPTODATE));
+
+ cl_assert((entry = git_index_get_bypath(index, "B", 0)));
+ cl_assert_equal_i(0, (entry->flags_extended & GIT_IDXENTRY_UPTODATE));
+
+ cl_assert((entry = git_index_get_bypath(index, "C", 0)));
+ cl_assert_equal_i(0, (entry->flags_extended & GIT_IDXENTRY_UPTODATE));
+
+ git_tree_free(tree);
+ git_index_free(index);
+}