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
;
33 int needed_rename_limit
;
34 int show_rename_progress
;
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
;
44 void init_merge_options(struct merge_options
*opt
, struct repository
*repo
);
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
);
50 * RETURN VALUES: All the merge_* functions below return a value as follows:
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.
58 * rename-detecting three-way merge, no recursion.
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
67 int merge_trees(struct merge_options
*opt
,
70 struct tree
*merge_base
);
73 * merge_recursive is like merge_trees() but with recursive ancestor
74 * consolidation and, if the commit is clean, creation of a commit.
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.
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
89 int merge_recursive(struct merge_options
*opt
,
92 struct commit_list
*merge_bases
,
93 struct commit
**result
);
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.
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
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
);