]>
Commit | Line | Data |
---|---|---|
e1b3a2ca DB |
1 | #ifndef MERGE_RECURSIVE_H |
2 | #define MERGE_RECURSIVE_H | |
3 | ||
696ee23c | 4 | #include "string-list.h" |
ef3ca954 EN |
5 | #include "unpack-trees.h" |
6 | ||
7 | struct commit; | |
696ee23c | 8 | |
0d6caa2d NTND |
9 | struct repository; |
10 | ||
8a2fce18 | 11 | struct merge_options { |
a779fb82 EN |
12 | struct repository *repo; |
13 | ||
14 | /* ref names used in console messages and conflict markers */ | |
4c5868f4 | 15 | const char *ancestor; |
8a2fce18 MV |
16 | const char *branch1; |
17 | const char *branch2; | |
a779fb82 EN |
18 | |
19 | /* rename related options */ | |
20 | int detect_renames; | |
8e012516 DS |
21 | enum { |
22 | MERGE_DIRECTORY_RENAMES_NONE = 0, | |
23 | MERGE_DIRECTORY_RENAMES_CONFLICT = 1, | |
24 | MERGE_DIRECTORY_RENAMES_TRUE = 2 | |
25 | } detect_directory_renames; | |
8599ab45 | 26 | int rename_limit; |
10ae7526 | 27 | int rename_score; |
99bfc669 | 28 | int show_rename_progress; |
a779fb82 EN |
29 | |
30 | /* xdiff-related options (patience, ignore whitespace, ours/theirs) */ | |
31 | long xdl_opts; | |
32 | enum { | |
33 | MERGE_RECURSIVE_NORMAL = 0, | |
34 | MERGE_RECURSIVE_OURS, | |
35 | MERGE_RECURSIVE_THEIRS | |
36 | } recursive_variant; | |
37 | ||
38 | /* console output related options */ | |
39 | int verbosity; | |
40 | unsigned buffer_output; /* 1: output at end, 2: keep buffered */ | |
41 | struct strbuf obuf; /* output buffer */ | |
42 | ||
43 | /* miscellaneous control options */ | |
44 | const char *subtree_shift; | |
45 | unsigned renormalize : 1; | |
46 | ||
47 | /* internal fields used by the implementation (do NOT set these) */ | |
5033639c | 48 | int call_depth; |
a779fb82 | 49 | int needed_rename_limit; |
fc65b00d | 50 | struct hashmap current_file_dir_set; |
70cc3d36 | 51 | struct string_list df_conflict_file_set; |
64b1abe9 | 52 | struct unpack_trees_options unpack_opts; |
a35edc84 | 53 | struct index_state orig_index; |
ea625cb0 EN |
54 | }; |
55 | ||
7c0a6c8e EN |
56 | void init_merge_options(struct merge_options *opt, struct repository *repo); |
57 | ||
58 | /* parse the option in s and update the relevant field of opt */ | |
59 | int parse_merge_opt(struct merge_options *opt, const char *s); | |
60 | ||
7fe40b88 | 61 | /* |
7c0a6c8e EN |
62 | * RETURN VALUES: All the merge_* functions below return a value as follows: |
63 | * > 0 Merge was clean | |
64 | * = 0 Merge had conflicts | |
65 | * < 0 Merge hit an unexpected and unrecoverable problem (e.g. disk | |
66 | * full) and aborted merge part-way through. | |
7fe40b88 | 67 | */ |
e95ab70a | 68 | |
7c0a6c8e EN |
69 | /* |
70 | * rename-detecting three-way merge, no recursion. | |
71 | * | |
72 | * Outputs: | |
73 | * - See RETURN VALUES above | |
74 | * - No commit is created | |
75 | * - opt->repo->index has the new index | |
76 | * - $GIT_INDEX_FILE is not updated | |
77 | * - The working tree is updated with results of the merge | |
78 | */ | |
79 | int merge_trees(struct merge_options *opt, | |
80 | struct tree *head, | |
81 | struct tree *merge, | |
82 | struct tree *merge_base); | |
85b46030 | 83 | |
b4db8a2b EN |
84 | /* |
85 | * merge_recursive is like merge_trees() but with recursive ancestor | |
7c0a6c8e | 86 | * consolidation and, if the commit is clean, creation of a commit. |
b4db8a2b EN |
87 | * |
88 | * NOTE: empirically, about a decade ago it was determined that with more | |
89 | * than two merge bases, optimal behavior was found when the | |
ff1bfa2c EN |
90 | * merge_bases were passed in the order of oldest commit to newest |
91 | * commit. Also, merge_bases will be consumed (emptied) so make a | |
92 | * copy if you need it. | |
7c0a6c8e EN |
93 | * |
94 | * Outputs: | |
95 | * - See RETURN VALUES above | |
96 | * - If merge is clean, a commit is created and its address written to *result | |
97 | * - opt->repo->index has the new index | |
98 | * - $GIT_INDEX_FILE is not updated | |
99 | * - The working tree is updated with results of the merge | |
b4db8a2b | 100 | */ |
c749ab1d | 101 | int merge_recursive(struct merge_options *opt, |
8a2fce18 | 102 | struct commit *h1, |
e1b3a2ca | 103 | struct commit *h2, |
ff1bfa2c | 104 | struct commit_list *merge_bases, |
e1b3a2ca DB |
105 | struct commit **result); |
106 | ||
b4db8a2b | 107 | /* |
7c0a6c8e EN |
108 | * merge_recursive_generic can operate on trees instead of commits, by |
109 | * wrapping the trees into virtual commits, and calling merge_recursive(). | |
110 | * It also writes out the in-memory index to disk if the merge is successful. | |
111 | * | |
112 | * Outputs: | |
113 | * - See RETURN VALUES above | |
114 | * - If merge is clean, a commit is created and its address written to *result | |
115 | * - opt->repo->index has the new index | |
116 | * - $GIT_INDEX_FILE is updated | |
117 | * - The working tree is updated with results of the merge | |
8a2fce18 | 118 | */ |
c749ab1d | 119 | int merge_recursive_generic(struct merge_options *opt, |
4e8161a8 | 120 | const struct object_id *head, |
121 | const struct object_id *merge, | |
ff1bfa2c EN |
122 | int num_merge_bases, |
123 | const struct object_id **merge_bases, | |
8a2fce18 MV |
124 | struct commit **result); |
125 | ||
e1b3a2ca | 126 | #endif |