]> git.proxmox.com Git - libgit2.git/blob - tests/merge/merge_helpers.h
Merge pull request #2183 from ethomson/merge_refactor
[libgit2.git] / tests / merge / merge_helpers.h
1 #ifndef INCLUDE_cl_merge_helpers_h__
2 #define INCLUDE_cl_merge_helpers_h__
3
4 #include "merge.h"
5 #include "git2/merge.h"
6
7 #define AUTOMERGEABLE_MERGED_FILE \
8 "this file is changed in master\n" \
9 "this file is automergeable\n" \
10 "this file is automergeable\n" \
11 "this file is automergeable\n" \
12 "this file is automergeable\n" \
13 "this file is automergeable\n" \
14 "this file is automergeable\n" \
15 "this file is automergeable\n" \
16 "this file is changed in branch\n"
17
18 #define AUTOMERGEABLE_MERGED_FILE_CRLF \
19 "this file is changed in master\r\n" \
20 "this file is automergeable\r\n" \
21 "this file is automergeable\r\n" \
22 "this file is automergeable\r\n" \
23 "this file is automergeable\r\n" \
24 "this file is automergeable\r\n" \
25 "this file is automergeable\r\n" \
26 "this file is automergeable\r\n" \
27 "this file is changed in branch\r\n"
28
29 #define CONFLICTING_MERGE_FILE \
30 "<<<<<<< HEAD\n" \
31 "this file is changed in master and branch\n" \
32 "=======\n" \
33 "this file is changed in branch and master\n" \
34 ">>>>>>> 7cb63eed597130ba4abb87b3e544b85021905520\n"
35
36 #define CONFLICTING_DIFF3_FILE \
37 "<<<<<<< HEAD\n" \
38 "this file is changed in master and branch\n" \
39 "||||||| initial\n" \
40 "this file is a conflict\n" \
41 "=======\n" \
42 "this file is changed in branch and master\n" \
43 ">>>>>>> 7cb63eed597130ba4abb87b3e544b85021905520\n"
44
45 #define CONFLICTING_UNION_FILE \
46 "this file is changed in master and branch\n" \
47 "this file is changed in branch and master\n"
48
49
50 struct merge_index_entry {
51 uint16_t mode;
52 char oid_str[41];
53 int stage;
54 char path[128];
55 };
56
57 struct merge_name_entry {
58 char ancestor_path[128];
59 char our_path[128];
60 char their_path[128];
61 };
62
63 struct merge_index_with_status {
64 struct merge_index_entry entry;
65 unsigned int status;
66 };
67
68 struct merge_reuc_entry {
69 char path[128];
70 unsigned int ancestor_mode;
71 unsigned int our_mode;
72 unsigned int their_mode;
73 char ancestor_oid_str[41];
74 char our_oid_str[41];
75 char their_oid_str[41];
76 };
77
78 struct merge_index_conflict_data {
79 struct merge_index_with_status ancestor;
80 struct merge_index_with_status ours;
81 struct merge_index_with_status theirs;
82 git_merge_diff_type_t change_type;
83 };
84
85 int merge_trees_from_branches(
86 git_index **index, git_repository *repo,
87 const char *ours_name, const char *theirs_name,
88 git_merge_options *opts);
89
90 int merge_commits_from_branches(
91 git_index **index, git_repository *repo,
92 const char *ours_name, const char *theirs_name,
93 git_merge_options *opts);
94
95 int merge_branches(git_repository *repo,
96 const char *ours_branch, const char *theirs_branch,
97 git_merge_options *merge_opts, git_checkout_options *checkout_opts);
98
99 int merge_test_diff_list(git_merge_diff_list *diff_list, const struct merge_index_entry expected[], size_t expected_len);
100
101 int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_conflict_data expected[], size_t expected_len);
102
103 int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len);
104
105 int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len);
106
107 int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], size_t expected_len);
108
109 int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len);
110
111 #endif