Documentation/gitprotocol-v2.txt: fix a slight inconsistency in format
[git/gitster.git] / merge-recursive.h
blobb88000e3c25277d07d20b7ba29755b9670cd28ff
1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
4 #include "strbuf.h"
6 struct commit;
7 struct commit_list;
8 struct object_id;
9 struct repository;
10 struct tree;
12 struct merge_options_internal;
13 struct merge_options {
14 struct repository *repo;
16 /* ref names used in console messages and conflict markers */
17 const char *ancestor;
18 const char *branch1;
19 const char *branch2;
21 /* rename related options */
22 int detect_renames;
23 enum {
24 MERGE_DIRECTORY_RENAMES_NONE = 0,
25 MERGE_DIRECTORY_RENAMES_CONFLICT = 1,
26 MERGE_DIRECTORY_RENAMES_TRUE = 2
27 } detect_directory_renames;
28 int rename_limit;
29 int rename_score;
30 int show_rename_progress;
32 /* xdiff-related options (patience, ignore whitespace, ours/theirs) */
33 long xdl_opts;
34 enum {
35 MERGE_VARIANT_NORMAL = 0,
36 MERGE_VARIANT_OURS,
37 MERGE_VARIANT_THEIRS
38 } recursive_variant;
40 /* console output related options */
41 int verbosity;
42 unsigned buffer_output; /* 1: output at end, 2: keep buffered */
43 struct strbuf obuf; /* output buffer; if buffer_output == 2, caller
44 * must handle and call strbuf_release */
46 /* miscellaneous control options */
47 const char *subtree_shift;
48 unsigned renormalize : 1;
49 unsigned record_conflict_msgs_as_headers : 1;
50 const char *msg_header_prefix;
52 /* internal fields used by the implementation */
53 struct merge_options_internal *priv;
56 void init_merge_options(struct merge_options *opt, struct repository *repo);
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);
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.
70 * rename-detecting three-way merge, no recursion.
72 * Outputs:
73 * - See RETURN VALUES above
74 * - opt->repo->index has the new index
75 * - new index NOT written to disk
76 * - The working tree is updated with results of the merge
78 int merge_trees(struct merge_options *opt,
79 struct tree *head,
80 struct tree *merge,
81 struct tree *merge_base);
84 * merge_recursive is like merge_trees() but with recursive ancestor
85 * consolidation.
87 * NOTE: empirically, about a decade ago it was determined that with more
88 * than two merge bases, optimal behavior was found when the
89 * merge_bases were passed in the order of oldest commit to newest
90 * commit. Also, merge_bases will be consumed (emptied) so make a
91 * copy if you need it.
93 * Outputs:
94 * - See RETURN VALUES above
95 * - *result is treated as scratch space for temporary recursive merges
96 * - opt->repo->index has the new index
97 * - new index NOT written to disk
98 * - The working tree is updated with results of the merge
100 int merge_recursive(struct merge_options *opt,
101 struct commit *h1,
102 struct commit *h2,
103 struct commit_list *merge_bases,
104 struct commit **result);
107 * merge_recursive_generic can operate on trees instead of commits, by
108 * wrapping the trees into virtual commits, and calling merge_recursive().
109 * It also writes out the in-memory index to disk if the merge is successful.
111 * Outputs:
112 * - See RETURN VALUES above
113 * - *result is treated as scratch space for temporary recursive merges
114 * - opt->repo->index has the new index
115 * - new index also written to $GIT_INDEX_FILE on disk
116 * - The working tree is updated with results of the merge
118 int merge_recursive_generic(struct merge_options *opt,
119 const struct object_id *head,
120 const struct object_id *merge,
121 int num_merge_bases,
122 const struct object_id **merge_bases,
123 struct commit **result);
125 #endif