]> git.ipfire.org Git - thirdparty/git.git/blob - merge-recursive.h
merge-recursive: use common name for ancestors/common/base_list
[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 /*
47 * For dir_rename_entry, directory names are stored as a full path from the
48 * toplevel of the repository and do not include a trailing '/'. Also:
49 *
50 * dir: original name of directory being renamed
51 * non_unique_new_dir: if true, could not determine new_dir
52 * new_dir: final name of directory being renamed
53 * possible_new_dirs: temporary used to help determine new_dir; see comments
54 * in get_directory_renames() for details
55 */
56 struct dir_rename_entry {
57 struct hashmap_entry ent; /* must be the first member! */
58 char *dir;
59 unsigned non_unique_new_dir:1;
60 struct strbuf new_dir;
61 struct string_list possible_new_dirs;
62 };
63
64 struct collision_entry {
65 struct hashmap_entry ent; /* must be the first member! */
66 char *target_file;
67 struct string_list source_files;
68 unsigned reported_already:1;
69 };
70
71 static inline int merge_detect_rename(struct merge_options *o)
72 {
73 return o->merge_detect_rename >= 0 ? o->merge_detect_rename :
74 o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
75 }
76
77 /*
78 * merge_recursive is like merge_trees() but with recursive ancestor
79 * consolidation, and when successful, it creates an actual commit
80 * and writes its address to *result.
81 *
82 * NOTE: empirically, about a decade ago it was determined that with more
83 * than two merge bases, optimal behavior was found when the
84 * merge_bases were passed in the order of oldest commit to newest
85 * commit. Also, merge_bases will be consumed (emptied) so make a
86 * copy if you need it.
87 */
88 int merge_recursive(struct merge_options *o,
89 struct commit *h1,
90 struct commit *h2,
91 struct commit_list *merge_bases,
92 struct commit **result);
93
94 /*
95 * rename-detecting three-way merge, no recursion; result of merge is written
96 * to opt->repo->index.
97 */
98 int merge_trees(struct merge_options *o,
99 struct tree *head,
100 struct tree *merge,
101 struct tree *merge_base);
102
103 /*
104 * "git-merge-recursive" can be fed trees; wrap them into
105 * virtual commits and call merge_recursive() proper.
106 */
107 int merge_recursive_generic(struct merge_options *o,
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 void init_merge_options(struct merge_options *o,
115 struct repository *repo);
116
117 int parse_merge_opt(struct merge_options *out, const char *s);
118
119 #endif