summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2018-09-18 11:04:40 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2018-09-18 11:04:40 +0200
commit4e72551edb91a6645273f38400c9196a942802ba (patch)
tree369ba4c4360cc9b769551e30c44cf702c7804eb3
parente181a649dfd9af86e272605274e645b7725819c4 (diff)
downloadlibgit2-cmn/index-add-conllision-extra.tar.gz
index: failing more thorough test for adding colliding pathcmn/index-add-conllision-extra
We've had tests since v0.21 that we error out when trying to add a colliding path to the index, but it turns out that right now we remove the already-existing path from the index instead of leaving it alone.
-rw-r--r--tests/index/collision.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/index/collision.c b/tests/index/collision.c
index 41eb7bfdc..f6f8d4a16 100644
--- a/tests/index/collision.c
+++ b/tests/index/collision.c
@@ -26,6 +26,7 @@ void test_index_collision__cleanup(void)
void test_index_collision__add(void)
{
git_index_entry entry;
+ git_tree_entry *tentry;
git_oid tree_id;
git_tree *tree;
@@ -39,12 +40,21 @@ void test_index_collision__add(void)
entry.path = "a/b";
cl_git_pass(git_index_add(g_index, &entry));
+ /* Check a/b exists here */
+ cl_git_pass(git_index_write_tree(&tree_id, g_index));
+ cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
+ cl_git_pass(git_tree_entry_bypath(&tentry, tree, "a/b"));
+ git_tree_entry_free(tentry);
+
/* create a tree/blob collision */
entry.path = "a/b/c";
cl_git_fail(git_index_add(g_index, &entry));
+ /* a/b should still exist here */
cl_git_pass(git_index_write_tree(&tree_id, g_index));
cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
+ cl_git_pass(git_tree_entry_bypath(&tentry, tree, "a/b"));
+ git_tree_entry_free(tentry);
git_tree_free(tree);
}