merge-recursive: comment and reorder the merge_options fields
[alt-git.git] / merge-recursive.h
blob9e040608fec98e09ac8fa01abc58ed724125735a
1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
4 #include "string-list.h"
5 #include "unpack-trees.h"
7 struct commit;
9 struct repository;
11 struct merge_options {
12 struct repository *repo;
14 /* ref names used in console messages and conflict markers */
15 const char *ancestor;
16 const char *branch1;
17 const char *branch2;
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;
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;
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 */
43 /* miscellaneous control options */
44 const char *subtree_shift;
45 unsigned renormalize : 1;
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;
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 * - 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
79 int merge_trees(struct merge_options *opt,
80 struct tree *head,
81 struct tree *merge,
82 struct tree *merge_base);
85 * merge_recursive is like merge_trees() but with recursive ancestor
86 * consolidation and, if the commit is clean, creation of a commit.
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.
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
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);
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.
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
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);
126 #endif