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