]> git.ipfire.org Git - thirdparty/git.git/blob - merge-recursive.h
merge-recursive: move some definitions around to clean up the header
[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 const char *ancestor;
13 const char *branch1;
14 const char *branch2;
15 enum {
16 MERGE_RECURSIVE_NORMAL = 0,
17 MERGE_RECURSIVE_OURS,
18 MERGE_RECURSIVE_THEIRS
19 } recursive_variant;
20 const char *subtree_shift;
21 unsigned buffer_output; /* 1: output at end, 2: keep buffered */
22 unsigned renormalize : 1;
23 long xdl_opts;
24 int verbosity;
25 enum {
26 MERGE_DIRECTORY_RENAMES_NONE = 0,
27 MERGE_DIRECTORY_RENAMES_CONFLICT = 1,
28 MERGE_DIRECTORY_RENAMES_TRUE = 2
29 } detect_directory_renames;
30 int diff_detect_rename;
31 int merge_detect_rename;
32 int diff_rename_limit;
33 int merge_rename_limit;
34 int rename_score;
35 int needed_rename_limit;
36 int show_rename_progress;
37 int call_depth;
38 struct strbuf obuf;
39 struct hashmap current_file_dir_set;
40 struct string_list df_conflict_file_set;
41 struct unpack_trees_options unpack_opts;
42 struct index_state orig_index;
43 struct repository *repo;
44 };
45
46 void init_merge_options(struct merge_options *opt, struct repository *repo);
47
48 /* parse the option in s and update the relevant field of opt */
49 int parse_merge_opt(struct merge_options *opt, const char *s);
50
51 /*
52 * RETURN VALUES: All the merge_* functions below return a value as follows:
53 * > 0 Merge was clean
54 * = 0 Merge had conflicts
55 * < 0 Merge hit an unexpected and unrecoverable problem (e.g. disk
56 * full) and aborted merge part-way through.
57 */
58
59 /*
60 * rename-detecting three-way merge, no recursion.
61 *
62 * Outputs:
63 * - See RETURN VALUES above
64 * - No commit is created
65 * - opt->repo->index has the new index
66 * - $GIT_INDEX_FILE is not updated
67 * - The working tree is updated with results of the merge
68 */
69 int merge_trees(struct merge_options *opt,
70 struct tree *head,
71 struct tree *merge,
72 struct tree *merge_base);
73
74 /*
75 * merge_recursive is like merge_trees() but with recursive ancestor
76 * consolidation and, if the commit is clean, creation of a commit.
77 *
78 * NOTE: empirically, about a decade ago it was determined that with more
79 * than two merge bases, optimal behavior was found when the
80 * merge_bases were passed in the order of oldest commit to newest
81 * commit. Also, merge_bases will be consumed (emptied) so make a
82 * copy if you need it.
83 *
84 * Outputs:
85 * - See RETURN VALUES above
86 * - If merge is clean, a commit is created and its address written to *result
87 * - opt->repo->index has the new index
88 * - $GIT_INDEX_FILE is not updated
89 * - The working tree is updated with results of the merge
90 */
91 int merge_recursive(struct merge_options *opt,
92 struct commit *h1,
93 struct commit *h2,
94 struct commit_list *merge_bases,
95 struct commit **result);
96
97 /*
98 * merge_recursive_generic can operate on trees instead of commits, by
99 * wrapping the trees into virtual commits, and calling merge_recursive().
100 * It also writes out the in-memory index to disk if the merge is successful.
101 *
102 * Outputs:
103 * - See RETURN VALUES above
104 * - If merge is clean, a commit is created and its address written to *result
105 * - opt->repo->index has the new index
106 * - $GIT_INDEX_FILE is updated
107 * - The working tree is updated with results of the merge
108 */
109 int merge_recursive_generic(struct merge_options *opt,
110 const struct object_id *head,
111 const struct object_id *merge,
112 int num_merge_bases,
113 const struct object_id **merge_bases,
114 struct commit **result);
115
116 #endif