1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
4 #include "string-list.h"
5 #include "unpack-trees.h"
11 struct merge_options
{
16 MERGE_RECURSIVE_NORMAL
= 0,
18 MERGE_RECURSIVE_THEIRS
20 const char *subtree_shift
;
21 unsigned buffer_output
; /* 1: output at end, 2: keep buffered */
22 unsigned renormalize
: 1;
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
;
35 int needed_rename_limit
;
36 int show_rename_progress
;
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
;
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:
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
56 struct dir_rename_entry
{
57 struct hashmap_entry ent
; /* must be the first member! */
59 unsigned non_unique_new_dir
:1;
60 struct strbuf new_dir
;
61 struct string_list possible_new_dirs
;
64 struct collision_entry
{
65 struct hashmap_entry ent
; /* must be the first member! */
67 struct string_list source_files
;
68 unsigned reported_already
:1;
71 static inline int merge_detect_rename(struct merge_options
*opt
)
73 return opt
->merge_detect_rename
>= 0 ? opt
->merge_detect_rename
:
74 opt
->diff_detect_rename
>= 0 ? opt
->diff_detect_rename
: 1;
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.
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.
88 int merge_recursive(struct merge_options
*opt
,
91 struct commit_list
*merge_bases
,
92 struct commit
**result
);
95 * rename-detecting three-way merge, no recursion; result of merge is written
96 * to opt->repo->index.
98 int merge_trees(struct merge_options
*opt
,
101 struct tree
*merge_base
);
104 * "git-merge-recursive" can be fed trees; wrap them into
105 * virtual commits and call merge_recursive() proper.
107 int merge_recursive_generic(struct merge_options
*opt
,
108 const struct object_id
*head
,
109 const struct object_id
*merge
,
111 const struct object_id
**merge_bases
,
112 struct commit
**result
);
114 void init_merge_options(struct merge_options
*opt
,
115 struct repository
*repo
);
117 int parse_merge_opt(struct merge_options
*opt
, const char *s
);