]>
Commit | Line | Data |
---|---|---|
651bfd69 ET |
1 | #include "clar_libgit2.h" |
2 | #include "git2/repository.h" | |
3 | #include "git2/merge.h" | |
4 | #include "merge.h" | |
5 | #include "../merge_helpers.h" | |
6 | #include "../conflict_data.h" | |
7 | ||
8 | static git_repository *repo; | |
9 | ||
10 | #define TEST_REPO_PATH "merge-recursive" | |
11 | ||
12 | void test_merge_workdir_recursive__initialize(void) | |
13 | { | |
14 | repo = cl_git_sandbox_init(TEST_REPO_PATH); | |
15 | } | |
16 | ||
17 | void test_merge_workdir_recursive__cleanup(void) | |
18 | { | |
19 | cl_git_sandbox_cleanup(); | |
20 | } | |
21 | ||
22 | void test_merge_workdir_recursive__writes_conflict_with_virtual_base(void) | |
23 | { | |
24 | git_index *index; | |
25 | git_merge_options opts = GIT_MERGE_OPTIONS_INIT; | |
e579e0f7 | 26 | git_str conflicting_buf = GIT_STR_INIT; |
651bfd69 ET |
27 | |
28 | struct merge_index_entry merge_index_entries[] = { | |
29 | { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, | |
30 | { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" }, | |
31 | { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" }, | |
32 | { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" }, | |
33 | { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" }, | |
34 | { 0100644, "fa567f568ed72157c0c617438d077695b99d9aac", 1, "veal.txt" }, | |
35 | { 0100644, "21950d5e4e4d1a871b4dfcf72ecb6b9c162c434e", 2, "veal.txt" }, | |
36 | { 0100644, "3855170cef875708da06ab9ad7fc6a73b531cda1", 3, "veal.txt" }, | |
37 | }; | |
38 | ||
651bfd69 ET |
39 | cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR "branchF-1", GIT_REFS_HEADS_DIR "branchF-2", &opts, NULL)); |
40 | ||
41 | cl_git_pass(git_repository_index(&index, repo)); | |
42 | cl_assert(merge_test_index(index, merge_index_entries, 8)); | |
43 | ||
44 | cl_git_pass(git_futils_readbuffer(&conflicting_buf, "merge-recursive/veal.txt")); | |
45 | ||
46 | cl_assert_equal_s(CONFLICTING_RECURSIVE_F1_TO_F2, conflicting_buf.ptr); | |
eae0bfdc | 47 | |
651bfd69 | 48 | git_index_free(index); |
e579e0f7 | 49 | git_str_dispose(&conflicting_buf); |
651bfd69 | 50 | } |
78859c63 ET |
51 | |
52 | void test_merge_workdir_recursive__conflicting_merge_base_with_diff3(void) | |
53 | { | |
54 | git_index *index; | |
55 | git_merge_options opts = GIT_MERGE_OPTIONS_INIT; | |
56 | git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; | |
e579e0f7 | 57 | git_str conflicting_buf = GIT_STR_INIT; |
78859c63 ET |
58 | |
59 | struct merge_index_entry merge_index_entries[] = { | |
60 | { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, | |
61 | { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" }, | |
62 | { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" }, | |
63 | { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" }, | |
64 | { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" }, | |
eae0bfdc PP |
65 | { 0100644, "0b01d2f70a1c6b9ab60c382f3f9cdc8173da6736", 1, "veal.txt" }, |
66 | { 0100644, "37a5054a9f9b4628e3924c5cb8f2147c6e2a3efc", 2, "veal.txt" }, | |
67 | { 0100644, "d604c75019c282144bdbbf3fd3462ba74b240efc", 3, "veal.txt" }, | |
78859c63 ET |
68 | }; |
69 | ||
70 | opts.file_flags |= GIT_MERGE_FILE_STYLE_DIFF3; | |
71 | checkout_opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_DIFF3; | |
72 | ||
eae0bfdc | 73 | cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR "branchH-2", GIT_REFS_HEADS_DIR "branchH-1", &opts, &checkout_opts)); |
78859c63 ET |
74 | |
75 | cl_git_pass(git_repository_index(&index, repo)); | |
76 | cl_assert(merge_test_index(index, merge_index_entries, 8)); | |
77 | ||
78 | cl_git_pass(git_futils_readbuffer(&conflicting_buf, "merge-recursive/veal.txt")); | |
79 | ||
eae0bfdc | 80 | cl_assert_equal_s(CONFLICTING_RECURSIVE_H2_TO_H1_WITH_DIFF3, conflicting_buf.ptr); |
78859c63 ET |
81 | |
82 | git_index_free(index); | |
e579e0f7 | 83 | git_str_dispose(&conflicting_buf); |
78859c63 | 84 | } |