1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
12 struct merge_options_internal
;
13 struct merge_options
{
14 struct repository
*repo
;
16 /* ref names used in console messages and conflict markers */
21 /* rename related options */
24 MERGE_DIRECTORY_RENAMES_NONE
= 0,
25 MERGE_DIRECTORY_RENAMES_CONFLICT
= 1,
26 MERGE_DIRECTORY_RENAMES_TRUE
= 2
27 } detect_directory_renames
;
30 int show_rename_progress
;
32 /* xdiff-related options (patience, ignore whitespace, ours/theirs) */
35 MERGE_VARIANT_NORMAL
= 0,
40 /* console output related options */
42 unsigned buffer_output
; /* 1: output at end, 2: keep buffered */
43 struct strbuf obuf
; /* output buffer; if buffer_output == 2, caller
44 * must handle and call strbuf_release */
46 /* miscellaneous control options */
47 const char *subtree_shift
;
48 unsigned renormalize
: 1;
50 /* internal fields used by the implementation */
51 struct merge_options_internal
*priv
;
54 void init_merge_options(struct merge_options
*opt
, struct repository
*repo
);
56 /* parse the option in s and update the relevant field of opt */
57 int parse_merge_opt(struct merge_options
*opt
, const char *s
);
60 * RETURN VALUES: All the merge_* functions below return a value as follows:
62 * = 0 Merge had conflicts
63 * < 0 Merge hit an unexpected and unrecoverable problem (e.g. disk
64 * full) and aborted merge part-way through.
68 * rename-detecting three-way merge, no recursion.
71 * - See RETURN VALUES above
72 * - No commit is created
73 * - opt->repo->index has the new index
74 * - $GIT_INDEX_FILE is not updated
75 * - The working tree is updated with results of the merge
77 int merge_trees(struct merge_options
*opt
,
80 struct tree
*merge_base
);
83 * merge_recursive is like merge_trees() but with recursive ancestor
84 * consolidation and, if the commit is clean, creation of a commit.
86 * NOTE: empirically, about a decade ago it was determined that with more
87 * than two merge bases, optimal behavior was found when the
88 * merge_bases were passed in the order of oldest commit to newest
89 * commit. Also, merge_bases will be consumed (emptied) so make a
90 * copy if you need it.
93 * - See RETURN VALUES above
94 * - If merge is clean, a commit is created and its address written to *result
95 * - opt->repo->index has the new index
96 * - $GIT_INDEX_FILE is not updated
97 * - The working tree is updated with results of the merge
99 int merge_recursive(struct merge_options
*opt
,
102 struct commit_list
*merge_bases
,
103 struct commit
**result
);
106 * merge_recursive_generic can operate on trees instead of commits, by
107 * wrapping the trees into virtual commits, and calling merge_recursive().
108 * It also writes out the in-memory index to disk if the merge is successful.
111 * - See RETURN VALUES above
112 * - If merge is clean, a commit is created and its address written to *result
113 * - opt->repo->index has the new index
114 * - $GIT_INDEX_FILE is updated
115 * - The working tree is updated with results of the merge
117 int merge_recursive_generic(struct merge_options
*opt
,
118 const struct object_id
*head
,
119 const struct object_id
*merge
,
121 const struct object_id
**merge_bases
,
122 struct commit
**result
);