1#ifndef MERGE_RECURSIVE_H
2#define MERGE_RECURSIVE_H
3
4#include "unpack-trees.h"
5#include "string-list.h"
6
7struct merge_options {
8 const char *ancestor;
9 const char *branch1;
10 const char *branch2;
11 enum {
12 MERGE_RECURSIVE_NORMAL = 0,
13 MERGE_RECURSIVE_OURS,
14 MERGE_RECURSIVE_THEIRS
15 } recursive_variant;
16 const char *subtree_shift;
17 unsigned buffer_output; /* 1: output at end, 2: keep buffered */
18 unsigned renormalize : 1;
19 long xdl_opts;
20 int verbosity;
21 int detect_directory_renames;
22 int diff_detect_rename;
23 int merge_detect_rename;
24 int diff_rename_limit;
25 int merge_rename_limit;
26 int rename_score;
27 int needed_rename_limit;
28 int show_rename_progress;
29 int call_depth;
30 struct strbuf obuf;
31 struct hashmap current_file_dir_set;
32 struct string_list df_conflict_file_set;
33 struct unpack_trees_options unpack_opts;
34 struct index_state orig_index;
35};
36
37/*
38 * For dir_rename_entry, directory names are stored as a full path from the
39 * toplevel of the repository and do not include a trailing '/'. Also:
40 *
41 * dir: original name of directory being renamed
42 * non_unique_new_dir: if true, could not determine new_dir
43 * new_dir: final name of directory being renamed
44 * possible_new_dirs: temporary used to help determine new_dir; see comments
45 * in get_directory_renames() for details
46 */
47struct dir_rename_entry {
48 struct hashmap_entry ent; /* must be the first member! */
49 char *dir;
50 unsigned non_unique_new_dir:1;
51 struct strbuf new_dir;
52 struct string_list possible_new_dirs;
53};
54
55struct collision_entry {
56 struct hashmap_entry ent; /* must be the first member! */
57 char *target_file;
58 struct string_list source_files;
59 unsigned reported_already:1;
60};
61
62static inline int merge_detect_rename(struct merge_options *o)
63{
64 return o->merge_detect_rename >= 0 ? o->merge_detect_rename :
65 o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
66}
67
68/* merge_trees() but with recursive ancestor consolidation */
69int merge_recursive(struct merge_options *o,
70 struct commit *h1,
71 struct commit *h2,
72 struct commit_list *ancestors,
73 struct commit **result);
74
75/* rename-detecting three-way merge, no recursion */
76int merge_trees(struct merge_options *o,
77 struct tree *head,
78 struct tree *merge,
79 struct tree *common,
80 struct tree **result);
81
82/*
83 * "git-merge-recursive" can be fed trees; wrap them into
84 * virtual commits and call merge_recursive() proper.
85 */
86int merge_recursive_generic(struct merge_options *o,
87 const struct object_id *head,
88 const struct object_id *merge,
89 int num_ca,
90 const struct object_id **ca,
91 struct commit **result);
92
93void init_merge_options(struct merge_options *o);
94struct tree *write_tree_from_memory(struct merge_options *o);
95
96int parse_merge_opt(struct merge_options *out, const char *s);
97
98#endif