summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-01-29 12:53:01 -0800
committerEdward Thomson <ethomson@microsoft.com>2014-01-29 13:15:53 -0800
commitbae8bea051806682fef48137e32f0305e94398b8 (patch)
treeb9c4bd44ccb5631d749851013db2ad8a9faf2e57
parent1eefd3561225bfdedfe52a7e9faa6e7c88d7a046 (diff)
downloadlibgit2-bae8bea051806682fef48137e32f0305e94398b8.tar.gz
More index collision tests
-rw-r--r--tests/index/collision.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/index/collision.c b/tests/index/collision.c
index 957418870..1f002e8d3 100644
--- a/tests/index/collision.c
+++ b/tests/index/collision.c
@@ -40,3 +40,67 @@ void test_index_collision__add(void)
git_tree_free(tree);
git_index_free(index);
}
+
+void test_index_collision__add_with_highstage_1(void)
+{
+ git_index *index;
+ git_index_entry entry;
+
+ repo = cl_git_sandbox_init("empty_standard_repo");
+ cl_git_pass(git_repository_index(&index, repo));
+
+ memset(&entry, 0, sizeof(entry));
+ entry.ctime.seconds = 12346789;
+ entry.mtime.seconds = 12346789;
+ entry.mode = 0100644;
+ entry.file_size = 0;
+ git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
+
+ entry.path = "a/b";
+ entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT);
+ cl_git_pass(git_index_add(index, &entry));
+
+ /* create a blob beneath the previous tree entry */
+ entry.path = "a/b/c";
+ entry.flags = 0;
+ cl_git_pass(git_index_add(index, &entry));
+
+ /* create another tree entry above the blob */
+ entry.path = "a/b";
+ entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT);
+ cl_git_pass(git_index_add(index, &entry));
+
+ git_index_free(index);
+}
+
+void test_index_collision__add_with_highstage_2(void)
+{
+ git_index *index;
+ git_index_entry entry;
+
+ repo = cl_git_sandbox_init("empty_standard_repo");
+ cl_git_pass(git_repository_index(&index, repo));
+
+ memset(&entry, 0, sizeof(entry));
+ entry.ctime.seconds = 12346789;
+ entry.mtime.seconds = 12346789;
+ entry.mode = 0100644;
+ entry.file_size = 0;
+ git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
+
+ entry.path = "a/b/c";
+ entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT);
+ cl_git_pass(git_index_add(index, &entry));
+
+ /* create a blob beneath the previous tree entry */
+ entry.path = "a/b/c";
+ entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT);
+ cl_git_pass(git_index_add(index, &entry));
+
+ /* create another tree entry above the blob */
+ entry.path = "a/b";
+ entry.flags = (3 << GIT_IDXENTRY_STAGESHIFT);
+ cl_git_pass(git_index_add(index, &entry));
+
+ git_index_free(index);
+}