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
;
46 void init_merge_options(struct merge_options
*opt
, struct repository
*repo
);
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
);
52 * RETURN VALUES: All the merge_* functions below return a value as follows:
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.
60 * rename-detecting three-way merge, no recursion.
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
69 int merge_trees(struct merge_options
*opt
,
72 struct tree
*merge_base
);
75 * merge_recursive is like merge_trees() but with recursive ancestor
76 * consolidation and, if the commit is clean, creation of a commit.
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.
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
91 int merge_recursive(struct merge_options
*opt
,
94 struct commit_list
*merge_bases
,
95 struct commit
**result
);
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.
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
109 int merge_recursive_generic(struct merge_options
*opt
,
110 const struct object_id
*head
,
111 const struct object_id
*merge
,
113 const struct object_id
**merge_bases
,
114 struct commit
**result
);