1 #include "clar_libgit2.h"
2 #include "git2/repository.h"
3 #include "git2/merge.h"
6 #include "../merge_helpers.h"
9 static git_repository
*repo
;
11 #define TEST_REPO_PATH "merge-whitespace"
13 #define BRANCH_A_EOL "branch_a_eol"
14 #define BRANCH_B_EOL "branch_b_eol"
16 #define BRANCH_A_CHANGE "branch_a_change"
17 #define BRANCH_B_CHANGE "branch_b_change"
19 // Fixture setup and teardown
20 void test_merge_trees_whitespace__initialize(void)
22 repo
= cl_git_sandbox_init(TEST_REPO_PATH
);
25 void test_merge_trees_whitespace__cleanup(void)
27 cl_git_sandbox_cleanup();
30 void test_merge_trees_whitespace__conflict(void)
33 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
35 struct merge_index_entry merge_index_entries
[] = {
36 { 0100644, "4026a6c83f39c56881c9ac62e7582db9e3d33a4f", 1, "test.txt" },
37 { 0100644, "c3b1fb31424c98072542cc8e42b48c92e52f494a", 2, "test.txt" },
38 { 0100644, "262f67de0de2e535a59ae1bc3c739601e98c354d", 3, "test.txt" },
41 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_EOL
, BRANCH_B_EOL
, &opts
));
43 cl_assert(merge_test_index(index
, merge_index_entries
, 3));
45 git_index_free(index
);
48 void test_merge_trees_whitespace__eol(void)
51 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
53 struct merge_index_entry merge_index_entries
[] = {
54 { 0100644, "ee3c2aac8e03224c323b58ecb1f9eef616745467", 0, "test.txt" },
57 opts
.file_flags
|= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL
;
59 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_EOL
, BRANCH_B_EOL
, &opts
));
61 cl_assert(merge_test_index(index
, merge_index_entries
, 1));
63 git_index_free(index
);
66 void test_merge_trees_whitespace__change(void)
69 git_merge_options opts
= GIT_MERGE_OPTIONS_INIT
;
71 struct merge_index_entry merge_index_entries
[] = {
72 { 0100644, "a827eab4fd66ab37a6ebcfaa7b7e341abfd55947", 0, "test.txt" },
75 opts
.file_flags
|= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE
;
77 cl_git_pass(merge_trees_from_branches(&index
, repo
, BRANCH_A_CHANGE
, BRANCH_B_CHANGE
, &opts
));
79 cl_assert(merge_test_index(index
, merge_index_entries
, 1));
81 git_index_free(index
);