]> git.proxmox.com Git - libgit2.git/blob - tests/libgit2/merge/trees/whitespace.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / merge / trees / whitespace.c
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 "futils.h"
7
8 static git_repository *repo;
9
10 #define TEST_REPO_PATH "merge-whitespace"
11
12 #define BRANCH_A_EOL "branch_a_eol"
13 #define BRANCH_B_EOL "branch_b_eol"
14
15 #define BRANCH_A_CHANGE "branch_a_change"
16 #define BRANCH_B_CHANGE "branch_b_change"
17
18 /* Fixture setup and teardown */
19 void test_merge_trees_whitespace__initialize(void)
20 {
21 repo = cl_git_sandbox_init(TEST_REPO_PATH);
22 }
23
24 void test_merge_trees_whitespace__cleanup(void)
25 {
26 cl_git_sandbox_cleanup();
27 }
28
29 void test_merge_trees_whitespace__conflict(void)
30 {
31 git_index *index;
32 git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
33
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" },
38 };
39
40 cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_A_EOL, BRANCH_B_EOL, &opts));
41
42 cl_assert(merge_test_index(index, merge_index_entries, 3));
43
44 git_index_free(index);
45 }
46
47 void test_merge_trees_whitespace__eol(void)
48 {
49 git_index *index;
50 git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
51
52 struct merge_index_entry merge_index_entries[] = {
53 { 0100644, "ee3c2aac8e03224c323b58ecb1f9eef616745467", 0, "test.txt" },
54 };
55
56 opts.file_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL;
57
58 cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_A_EOL, BRANCH_B_EOL, &opts));
59
60 cl_assert(merge_test_index(index, merge_index_entries, 1));
61
62 git_index_free(index);
63 }
64
65 void test_merge_trees_whitespace__change(void)
66 {
67 git_index *index;
68 git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
69
70 struct merge_index_entry merge_index_entries[] = {
71 { 0100644, "a827eab4fd66ab37a6ebcfaa7b7e341abfd55947", 0, "test.txt" },
72 };
73
74 opts.file_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE;
75
76 cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_A_CHANGE, BRANCH_B_CHANGE, &opts));
77
78 cl_assert(merge_test_index(index, merge_index_entries, 1));
79
80 git_index_free(index);
81 }