]> git.ipfire.org Git - thirdparty/git.git/blob - merge-recursive.h
merge-recursive: comment and reorder the merge_options fields
[thirdparty/git.git] / merge-recursive.h
1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
3
4 #include "string-list.h"
5 #include "unpack-trees.h"
6
7 struct commit;
8
9 struct repository;
10
11 struct merge_options {
12 struct repository *repo;
13
14 /* ref names used in console messages and conflict markers */
15 const char *ancestor;
16 const char *branch1;
17 const char *branch2;
18
19 /* rename related options */
20 int detect_renames;
21 enum {
22 MERGE_DIRECTORY_RENAMES_NONE = 0,
23 MERGE_DIRECTORY_RENAMES_CONFLICT = 1,
24 MERGE_DIRECTORY_RENAMES_TRUE = 2
25 } detect_directory_renames;
26 int rename_limit;
27 int rename_score;
28 int show_rename_progress;
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) */
48 int call_depth;
49 int needed_rename_limit;
50 struct hashmap current_file_dir_set;
51 struct string_list df_conflict_file_set;
52 struct unpack_trees_options unpack_opts;
53 struct index_state orig_index;
54 };
55
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
61 /*
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.
67 */
68
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);
83
84 /*
85 * merge_recursive is like merge_trees() but with recursive ancestor
86 * consolidation and, if the commit is clean, creation of a commit.
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
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.
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
100 */
101 int merge_recursive(struct merge_options *opt,
102 struct commit *h1,
103 struct commit *h2,
104 struct commit_list *merge_bases,
105 struct commit **result);
106
107 /*
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
118 */
119 int merge_recursive_generic(struct merge_options *opt,
120 const struct object_id *head,
121 const struct object_id *merge,
122 int num_merge_bases,
123 const struct object_id **merge_bases,
124 struct commit **result);
125
126 #endif