summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-18 22:27:34 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-06-26 09:52:36 +0100
commitc4ce017fd5e829a81860470fc4a26ae34f537841 (patch)
tree126c858738d8f95920d15daf28084c5f7bcf56c4
parente6cdd17c846648aa8e1e025fa1988475886a551e (diff)
downloadlibgit2-c4ce017fd5e829a81860470fc4a26ae34f537841.tar.gz
index::names tests: add conflicts with high stages
We add entries into the main index to correspond with the NAME entries that we're going to test. NAME entries store the results of conflicts occuring with rename detection during merge, and they must correspond to conflicts in the index. This test was mistakenly adding regular entries. The checkout validation failed, since it requires NAME entries to correspond to high-stage (conflict) entries. Correct the test to actually create conflicts.
-rw-r--r--tests/index/names.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/index/names.c b/tests/index/names.c
index d462088b2..664ddd183 100644
--- a/tests/index/names.c
+++ b/tests/index/names.c
@@ -25,10 +25,47 @@ void test_index_names__cleanup(void)
cl_git_sandbox_cleanup();
}
+static void index_add_conflicts(void)
+{
+ git_index_entry entry = {{0}};
+ const char *paths[][3] = {
+ { "ancestor", "ours", "theirs" },
+ { "ancestor2", "ours2", "theirs2" },
+ { "ancestor3", "ours3", "theirs3" } };
+ const char **conflict;
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(paths); i++) {
+ conflict = paths[i];
+
+ /* ancestor */
+ entry.path = conflict[0];
+ entry.mode = GIT_FILEMODE_BLOB;
+ GIT_IDXENTRY_STAGE_SET(&entry, GIT_INDEX_STAGE_ANCESTOR);
+ git_oid_fromstr(&entry.id, "1f85ca51b8e0aac893a621b61a9c2661d6aa6d81");
+ cl_git_pass(git_index_add(repo_index, &entry));
+
+ /* ours */
+ entry.path = conflict[1];
+ entry.mode = GIT_FILEMODE_BLOB;
+ GIT_IDXENTRY_STAGE_SET(&entry, GIT_INDEX_STAGE_OURS);
+ git_oid_fromstr(&entry.id, "1f85ca51b8e0aac893a621b61a9c2661d6aa6d81");
+ cl_git_pass(git_index_add(repo_index, &entry));
+
+ /* theirs */
+ entry.path = conflict[2];
+ entry.mode = GIT_FILEMODE_BLOB;
+ GIT_IDXENTRY_STAGE_SET(&entry, GIT_INDEX_STAGE_THEIRS);
+ git_oid_fromstr(&entry.id, "1f85ca51b8e0aac893a621b61a9c2661d6aa6d81");
+ cl_git_pass(git_index_add(repo_index, &entry));
+ }
+}
+
void test_index_names__add(void)
{
const git_index_name_entry *conflict_name;
+ index_add_conflicts();
cl_git_pass(git_index_name_add(repo_index, "ancestor", "ours", "theirs"));
cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL));
cl_git_pass(git_index_name_add(repo_index, "ancestor3", NULL, "theirs3"));