diff options
Diffstat (limited to 'tests/index')
| -rw-r--r-- | tests/index/addall.c | 153 | ||||
| -rw-r--r-- | tests/index/collision.c | 10 | ||||
| -rw-r--r-- | tests/index/conflicts.c | 75 |
3 files changed, 175 insertions, 63 deletions
diff --git a/tests/index/addall.c b/tests/index/addall.c index 377d2079e..211e76228 100644 --- a/tests/index/addall.c +++ b/tests/index/addall.c @@ -12,10 +12,7 @@ void test_index_addall__initialize(void) void test_index_addall__cleanup(void) { - git_repository_free(g_repo); - g_repo = NULL; - - cl_fixture_cleanup(TEST_DIR); + cl_git_sandbox_cleanup(); } #define STATUS_INDEX_FLAGS \ @@ -36,6 +33,7 @@ typedef struct { size_t wt_dels; size_t wt_mods; size_t ignores; + size_t conflicts; } index_status_counts; static int index_status_cb( @@ -67,6 +65,8 @@ static int index_status_cb( if (status_flags & GIT_STATUS_IGNORED) vals->ignores++; + if (status_flags & GIT_STATUS_CONFLICTED) + vals->conflicts++; return 0; } @@ -75,7 +75,7 @@ static void check_status_at_line( git_repository *repo, size_t index_adds, size_t index_dels, size_t index_mods, size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores, - const char *file, int line) + size_t conflicts, const char *file, int line) { index_status_counts vals; @@ -97,10 +97,12 @@ static void check_status_at_line( file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods); clar__assert_equal( file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores); + clar__assert_equal( + file,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts); } -#define check_status(R,IA,ID,IM,WA,WD,WM,IG) \ - check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,__FILE__,__LINE__) +#define check_status(R,IA,ID,IM,WA,WD,WM,IG,C) \ + check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__LINE__) static void check_stat_data(git_index *index, const char *path, bool match) { @@ -137,21 +139,22 @@ static void check_stat_data(git_index *index, const char *path, bool match) static void addall_create_test_repo(bool check_every_step) { - cl_git_pass(git_repository_init(&g_repo, TEST_DIR, false)); + g_repo = cl_git_sandbox_init_new(TEST_DIR); + if (check_every_step) - check_status(g_repo, 0, 0, 0, 0, 0, 0, 0); + check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0); cl_git_mkfile(TEST_DIR "/file.foo", "a file"); if (check_every_step) - check_status(g_repo, 0, 0, 0, 1, 0, 0, 0); + check_status(g_repo, 0, 0, 0, 1, 0, 0, 0, 0); cl_git_mkfile(TEST_DIR "/.gitignore", "*.foo\n"); if (check_every_step) - check_status(g_repo, 0, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 1, 0, 0, 1, 0); cl_git_mkfile(TEST_DIR "/file.bar", "another file"); if (check_every_step) - check_status(g_repo, 0, 0, 0, 2, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 2, 0, 0, 1, 0); } void test_index_addall__repo_lifecycle(void) @@ -171,107 +174,107 @@ void test_index_addall__repo_lifecycle(void) cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.bar", true); - check_status(g_repo, 1, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0); cl_git_rewritefile(TEST_DIR "/file.bar", "new content for file"); check_stat_data(index, TEST_DIR "/file.bar", false); - check_status(g_repo, 1, 0, 0, 1, 0, 1, 1); + check_status(g_repo, 1, 0, 0, 1, 0, 1, 1, 0); cl_git_mkfile(TEST_DIR "/file.zzz", "yet another one"); cl_git_mkfile(TEST_DIR "/other.zzz", "yet another one"); cl_git_mkfile(TEST_DIR "/more.zzz", "yet another one"); - check_status(g_repo, 1, 0, 0, 4, 0, 1, 1); + check_status(g_repo, 1, 0, 0, 4, 0, 1, 1, 0); cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.bar", true); - check_status(g_repo, 1, 0, 0, 4, 0, 0, 1); + check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0); cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.zzz", true); - check_status(g_repo, 2, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0); cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "first commit"); - check_status(g_repo, 0, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); if (cl_repo_get_bool(g_repo, "core.filemode")) { cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0777)); cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); - check_status(g_repo, 0, 0, 1, 3, 0, 0, 1); + check_status(g_repo, 0, 0, 1, 3, 0, 0, 1, 0); /* go back to what we had before */ cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0666)); cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); - check_status(g_repo, 0, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); } /* attempt to add an ignored file - does nothing */ strs[0] = "file.foo"; cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); - check_status(g_repo, 0, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); /* add with check - should generate error */ error = git_index_add_all( index, &paths, GIT_INDEX_ADD_CHECK_PATHSPEC, NULL, NULL); cl_assert_equal_i(GIT_EINVALIDSPEC, error); - check_status(g_repo, 0, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); /* add with force - should allow */ cl_git_pass(git_index_add_all( index, &paths, GIT_INDEX_ADD_FORCE, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.foo", true); - check_status(g_repo, 1, 0, 0, 3, 0, 0, 0); + check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0); /* now it's in the index, so regular add should work */ cl_git_rewritefile(TEST_DIR "/file.foo", "new content for file"); check_stat_data(index, TEST_DIR "/file.foo", false); - check_status(g_repo, 1, 0, 0, 3, 0, 1, 0); + check_status(g_repo, 1, 0, 0, 3, 0, 1, 0, 0); cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.foo", true); - check_status(g_repo, 1, 0, 0, 3, 0, 0, 0); + check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0); cl_git_pass(git_index_add_bypath(index, "more.zzz")); check_stat_data(index, TEST_DIR "/more.zzz", true); - check_status(g_repo, 2, 0, 0, 2, 0, 0, 0); + check_status(g_repo, 2, 0, 0, 2, 0, 0, 0, 0); cl_git_rewritefile(TEST_DIR "/file.zzz", "new content for file"); - check_status(g_repo, 2, 0, 0, 2, 0, 1, 0); + check_status(g_repo, 2, 0, 0, 2, 0, 1, 0, 0); cl_git_pass(git_index_add_bypath(index, "file.zzz")); check_stat_data(index, TEST_DIR "/file.zzz", true); - check_status(g_repo, 2, 0, 1, 2, 0, 0, 0); + check_status(g_repo, 2, 0, 1, 2, 0, 0, 0, 0); strs[0] = "*.zzz"; cl_git_pass(git_index_remove_all(index, &paths, NULL, NULL)); - check_status(g_repo, 1, 1, 0, 4, 0, 0, 0); + check_status(g_repo, 1, 1, 0, 4, 0, 0, 0, 0); cl_git_pass(git_index_add_bypath(index, "file.zzz")); - check_status(g_repo, 1, 0, 1, 3, 0, 0, 0); + check_status(g_repo, 1, 0, 1, 3, 0, 0, 0, 0); cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "second commit"); - check_status(g_repo, 0, 0, 0, 3, 0, 0, 0); + check_status(g_repo, 0, 0, 0, 3, 0, 0, 0, 0); cl_must_pass(p_unlink(TEST_DIR "/file.zzz")); - check_status(g_repo, 0, 0, 0, 3, 1, 0, 0); + check_status(g_repo, 0, 0, 0, 3, 1, 0, 0, 0); /* update_all should be able to remove entries */ cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); - check_status(g_repo, 0, 1, 0, 3, 0, 0, 0); + check_status(g_repo, 0, 1, 0, 3, 0, 0, 0, 0); strs[0] = "*"; cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); - check_status(g_repo, 3, 1, 0, 0, 0, 0, 0); + check_status(g_repo, 3, 1, 0, 0, 0, 0, 0, 0); /* must be able to remove at any position while still updating other files */ cl_must_pass(p_unlink(TEST_DIR "/.gitignore")); cl_git_rewritefile(TEST_DIR "/file.zzz", "reconstructed file"); cl_git_rewritefile(TEST_DIR "/more.zzz", "altered file reality"); - check_status(g_repo, 3, 1, 0, 1, 1, 1, 0); + check_status(g_repo, 3, 1, 0, 1, 1, 1, 0, 0); cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); - check_status(g_repo, 2, 1, 0, 1, 0, 0, 0); + check_status(g_repo, 2, 1, 0, 1, 0, 0, 0, 0); /* this behavior actually matches 'git add -u' where "file.zzz" has * been removed from the index, so when you go to update, even though * it exists in the HEAD, it is not re-added to the index, leaving it @@ -293,14 +296,14 @@ void test_index_addall__files_in_folders(void) cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.bar", true); - check_status(g_repo, 2, 0, 0, 0, 0, 0, 1); + check_status(g_repo, 2, 0, 0, 0, 0, 0, 1, 0); cl_must_pass(p_mkdir(TEST_DIR "/subdir", 0777)); cl_git_mkfile(TEST_DIR "/subdir/file", "hello!\n"); - check_status(g_repo, 2, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 2, 0, 0, 1, 0, 0, 1, 0); cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); - check_status(g_repo, 3, 0, 0, 0, 0, 0, 1); + check_status(g_repo, 3, 0, 0, 0, 0, 0, 1, 0); git_index_free(index); } @@ -337,7 +340,7 @@ void test_index_addall__callback_filtering(void) cl_git_pass( git_index_add_all(index, NULL, 0, addall_match_prefix, "file.")); check_stat_data(index, TEST_DIR "/file.bar", true); - check_status(g_repo, 1, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0); cl_git_mkfile(TEST_DIR "/file.zzz", "yet another one"); cl_git_mkfile(TEST_DIR "/more.zzz", "yet another one"); @@ -345,32 +348,32 @@ void test_index_addall__callback_filtering(void) cl_git_pass(git_index_update_all(index, NULL, NULL, NULL)); check_stat_data(index, TEST_DIR "/file.bar", true); - check_status(g_repo, 1, 0, 0, 4, 0, 0, 1); + check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0); cl_git_pass( git_index_add_all(index, NULL, 0, addall_match_prefix, "other")); check_stat_data(index, TEST_DIR "/other.zzz", true); - check_status(g_repo, 2, 0, 0, 3, 0, 0, 1); + check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0); cl_git_pass( git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz")); - check_status(g_repo, 4, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 4, 0, 0, 1, 0, 0, 1, 0); cl_git_pass( git_index_remove_all(index, NULL, addall_match_suffix, ".zzz")); - check_status(g_repo, 1, 0, 0, 4, 0, 0, 1); + check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0); cl_git_fail_with( git_index_add_all(index, NULL, 0, addall_cancel_at, "more.zzz"), -123); - check_status(g_repo, 3, 0, 0, 2, 0, 0, 1); + check_status(g_repo, 3, 0, 0, 2, 0, 0, 1, 0); cl_git_fail_with( git_index_add_all(index, NULL, 0, addall_cancel_at, "other.zzz"), -123); - check_status(g_repo, 4, 0, 0, 1, 0, 0, 1); + check_status(g_repo, 4, 0, 0, 1, 0, 0, 1, 0); cl_git_pass( git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz")); - check_status(g_repo, 5, 0, 0, 0, 0, 0, 1); + check_status(g_repo, 5, 0, 0, 0, 0, 0, 1, 0); cl_must_pass(p_unlink(TEST_DIR "/file.zzz")); cl_must_pass(p_unlink(TEST_DIR "/more.zzz")); @@ -380,13 +383,65 @@ void test_index_addall__callback_filtering(void) git_index_update_all(index, NULL, addall_cancel_at, "more.zzz"), -123); /* file.zzz removed from index (so Index Adds 5 -> 4) and * more.zzz + other.zzz removed (so Worktree Dels 0 -> 2) */ - check_status(g_repo, 4, 0, 0, 0, 2, 0, 1); + check_status(g_repo, 4, 0, 0, 0, 2, 0, 1, 0); cl_git_fail_with( git_index_update_all(index, NULL, addall_cancel_at, "other.zzz"), -123); /* more.zzz removed from index (so Index Adds 4 -> 3) and * Just other.zzz removed (so Worktree Dels 2 -> 1) */ - check_status(g_repo, 3, 0, 0, 0, 1, 0, 1); + check_status(g_repo, 3, 0, 0, 0, 1, 0, 1, 0); git_index_free(index); } + +void test_index_addall__adds_conflicts(void) +{ + git_index *index; + git_reference *ref; + git_annotated_commit *annotated; + + g_repo = cl_git_sandbox_init("merge-resolve"); + cl_git_pass(git_repository_index(&index, g_repo)); + + check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0); + + cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/branch")); + cl_git_pass(git_annotated_commit_from_ref(&annotated, g_repo, ref)); + + cl_git_pass(git_merge(g_repo, &annotated, 1, NULL, NULL)); + check_status(g_repo, 0, 1, 2, 0, 0, 0, 0, 1); + + cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); + check_status(g_repo, 0, 1, 3, 0, 0, 0, 0, 0); + + git_annotated_commit_free(annotated); + git_reference_free(ref); + git_index_free(index); +} + +void test_index_addall__removes_deleted_conflicted_files(void) +{ + git_index *index; + git_reference *ref; + git_annotated_commit *annotated; + + g_repo = cl_git_sandbox_init("merge-resolve"); + cl_git_pass(git_repository_index(&index, g_repo)); + + check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0); + + cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/branch")); + cl_git_pass(git_annotated_commit_from_ref(&annotated, g_repo, ref)); + + cl_git_pass(git_merge(g_repo, &annotated, 1, NULL, NULL)); + check_status(g_repo, 0, 1, 2, 0, 0, 0, 0, 1); + + cl_git_rmfile("merge-resolve/conflicting.txt"); + + cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); + check_status(g_repo, 0, 2, 2, 0, 0, 0, 0, 0); + + git_annotated_commit_free(annotated); + git_reference_free(ref); + git_index_free(index); +}
\ No newline at end of file diff --git a/tests/index/collision.c b/tests/index/collision.c index 1f002e8d3..19c1548e9 100644 --- a/tests/index/collision.c +++ b/tests/index/collision.c @@ -57,7 +57,7 @@ void test_index_collision__add_with_highstage_1(void) git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"); entry.path = "a/b"; - entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT); + GIT_IDXENTRY_STAGE_SET(&entry, 2); cl_git_pass(git_index_add(index, &entry)); /* create a blob beneath the previous tree entry */ @@ -67,7 +67,7 @@ void test_index_collision__add_with_highstage_1(void) /* create another tree entry above the blob */ entry.path = "a/b"; - entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT); + GIT_IDXENTRY_STAGE_SET(&entry, 1); cl_git_pass(git_index_add(index, &entry)); git_index_free(index); @@ -89,17 +89,17 @@ void test_index_collision__add_with_highstage_2(void) git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"); entry.path = "a/b/c"; - entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT); + GIT_IDXENTRY_STAGE_SET(&entry, 1); 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); + GIT_IDXENTRY_STAGE_SET(&entry, 2); 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); + GIT_IDXENTRY_STAGE_SET(&entry, 3); cl_git_pass(git_index_add(index, &entry)); git_index_free(index); diff --git a/tests/index/conflicts.c b/tests/index/conflicts.c index 427351693..b7a2456eb 100644 --- a/tests/index/conflicts.c +++ b/tests/index/conflicts.c @@ -16,6 +16,7 @@ static git_index *repo_index; #define CONFLICTS_TWO_OUR_OID "8b3f43d2402825c200f835ca1762413e386fd0b2" #define CONFLICTS_TWO_THEIR_OID "220bd62631c8cf7a83ef39c6b94595f00517211e" +#define TEST_STAGED_OID "beefdadafeedabedcafedeedbabedeadbeaddeaf" #define TEST_ANCESTOR_OID "f00ff00ff00ff00ff00ff00ff00ff00ff00ff00f" #define TEST_OUR_OID "b44bb44bb44bb44bb44bb44bb44bb44bb44bb44b" #define TEST_THEIR_OID "0123456789abcdef0123456789abcdef01234567" @@ -46,15 +47,18 @@ void test_index_conflicts__add(void) memset(&their_entry, 0x0, sizeof(git_index_entry)); ancestor_entry.path = "test-one.txt"; - ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT); + ancestor_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1); git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); our_entry.path = "test-one.txt"; - ancestor_entry.flags |= (2 << GIT_IDXENTRY_STAGESHIFT); + our_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&our_entry, 2); git_oid_fromstr(&our_entry.id, TEST_OUR_OID); their_entry.path = "test-one.txt"; - ancestor_entry.flags |= (3 << GIT_IDXENTRY_STAGESHIFT); + their_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 2); git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); @@ -74,15 +78,18 @@ void test_index_conflicts__add_fixes_incorrect_stage(void) memset(&their_entry, 0x0, sizeof(git_index_entry)); ancestor_entry.path = "test-one.txt"; - ancestor_entry.flags |= (3 << GIT_IDXENTRY_STAGESHIFT); + ancestor_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3); git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); our_entry.path = "test-one.txt"; - ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT); + our_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&our_entry, 1); git_oid_fromstr(&our_entry.id, TEST_OUR_OID); their_entry.path = "test-one.txt"; - ancestor_entry.flags |= (2 << GIT_IDXENTRY_STAGESHIFT); + their_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&their_entry, 2); git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); @@ -96,6 +103,55 @@ void test_index_conflicts__add_fixes_incorrect_stage(void) cl_assert(git_index_entry_stage(conflict_entry[2]) == 3); } +void test_index_conflicts__add_removes_stage_zero(void) +{ + git_index_entry staged, ancestor_entry, our_entry, their_entry; + const git_index_entry *conflict_entry[3]; + + cl_assert(git_index_entrycount(repo_index) == 8); + + memset(&staged, 0x0, sizeof(git_index_entry)); + memset(&ancestor_entry, 0x0, sizeof(git_index_entry)); + memset(&our_entry, 0x0, sizeof(git_index_entry)); + memset(&their_entry, 0x0, sizeof(git_index_entry)); + + staged.path = "test-one.txt"; + staged.mode = 0100644; + git_oid_fromstr(&staged.id, TEST_STAGED_OID); + cl_git_pass(git_index_add(repo_index, &staged)); + cl_assert(git_index_entrycount(repo_index) == 9); + + ancestor_entry.path = "test-one.txt"; + ancestor_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3); + git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); + + our_entry.path = "test-one.txt"; + our_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&our_entry, 1); + git_oid_fromstr(&our_entry.id, TEST_OUR_OID); + + their_entry.path = "test-one.txt"; + their_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&their_entry, 2); + git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); + + cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); + + cl_assert(git_index_entrycount(repo_index) == 11); + + cl_assert_equal_p(NULL, git_index_get_bypath(repo_index, "test-one.txt", 0)); + + cl_git_pass(git_index_conflict_get(&conflict_entry[0], &conflict_entry[1], &conflict_entry[2], repo_index, "test-one.txt")); + + cl_assert_equal_oid(&ancestor_entry.id, &conflict_entry[0]->id); + cl_assert_equal_i(1, git_index_entry_stage(conflict_entry[0])); + cl_assert_equal_oid(&our_entry.id, &conflict_entry[1]->id); + cl_assert_equal_i(2, git_index_entry_stage(conflict_entry[1])); + cl_assert_equal_oid(&their_entry.id, &conflict_entry[2]->id); + cl_assert_equal_i(3, git_index_entry_stage(conflict_entry[2])); +} + void test_index_conflicts__get(void) { const git_index_entry *conflict_entry[3]; @@ -216,7 +272,7 @@ void test_index_conflicts__moved_to_reuc_on_add(void) cl_assert(entry = git_index_get_byindex(repo_index, i)); if (strcmp(entry->path, "conflicts-one.txt") == 0) - cl_assert(git_index_entry_stage(entry) == 0); + cl_assert(!git_index_entry_is_conflict(entry)); } } @@ -256,7 +312,7 @@ void test_index_conflicts__remove_all_conflicts(void) for (i = 0; i < git_index_entrycount(repo_index); i++) { cl_assert(entry = git_index_get_byindex(repo_index, i)); - cl_assert(git_index_entry_stage(entry) == 0); + cl_assert(!git_index_entry_is_conflict(entry)); } } @@ -272,7 +328,8 @@ void test_index_conflicts__partial(void) memset(&their_entry, 0x0, sizeof(git_index_entry)); ancestor_entry.path = "test-one.txt"; - ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT); + ancestor_entry.mode = 0100644; + GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1); git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, NULL, NULL)); |
