1 #include "clar_libgit2.h"
2 #include "git2/repository.h"
3 #include "git2/merge.h"
5 #include "../merge_helpers.h"
8 static git_repository
*repo
;
10 #define TEST_REPO_PATH "merge-whitespace"
12 #define BRANCH_A_EOL "branch_a_eol"
13 #define BRANCH_B_EOL "branch_b_eol"
15 #define BRANCH_A_CHANGE "branch_a_change"
16 #define BRANCH_B_CHANGE "branch_b_change"
18 /* Fixture setup and teardown */
19 void test_merge_trees_whitespace__initialize(void)
21 repo
= cl_git_sandbox_init(TEST_REPO_PATH
);
24 void test_merge_trees_whitespace__cleanup(void)
26 cl_git_sandbox_cleanup();
29 void test_merge_trees_whitespace__conflict(void)
32 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
34 struct merge_index_entry merge_index_entries
[] = {
35 { 0100644, "4026a6c83f39c56881c9ac62e7582db9e3d33a4f", 1, "test.txt" },
36 { 0100644, "c3b1fb31424c98072542cc8e42b48c92e52f494a", 2, "test.txt" },
37 { 0100644, "262f67de0de2e535a59ae1bc3c739601e98c354d", 3, "test.txt" },
40 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_EOL
, BRANCH_B_EOL
, &opts
));
42 cl_assert(merge_test_index(index
, merge_index_entries
, 3));
44 git_index_free(index
);
47 void test_merge_trees_whitespace__eol(void)
50 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
52 struct merge_index_entry merge_index_entries
[] = {
53 { 0100644, "ee3c2aac8e03224c323b58ecb1f9eef616745467", 0, "test.txt" },
56 opts
.file_flags
|= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL
;
58 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_EOL
, BRANCH_B_EOL
, &opts
));
60 cl_assert(merge_test_index(index
, merge_index_entries
, 1));
62 git_index_free(index
);
65 void test_merge_trees_whitespace__change(void)
68 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
70 struct merge_index_entry merge_index_entries
[] = {
71 { 0100644, "a827eab4fd66ab37a6ebcfaa7b7e341abfd55947", 0, "test.txt" },
74 opts
.file_flags
|= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE
;
76 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_CHANGE
, BRANCH_B_CHANGE
, &opts
));
78 cl_assert(merge_test_index(index
, merge_index_entries
, 1));
80 git_index_free(index
);