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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/tests/index/names.c b/tests/index/names.c
index d462088..664ddd1 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"));