14 * Whether the merge is clean; possible values:
16 * 0: not clean (merge conflicts)
17 * <0: operation aborted prematurely. (object database
18 * unreadable, disk full, etc.) Worktree may be left in an
19 * inconsistent state if operation failed near the end.
24 * Result of merge. If !clean, represents what would go in worktree
25 * (thus possibly including files containing conflict markers).
30 * Special messages and conflict notices for various paths
32 * This is a map of pathnames to a string_list. It contains various
33 * warning/conflict/notice messages (possibly multiple per path)
34 * that callers may want to use.
36 struct strmap
*path_messages
;
39 * Additional metadata used by merge_switch_to_result() or future calls
40 * to merge_incore_*(). Includes data needed to update the index (if
41 * !clean) and to print "CONFLICT" messages. Not for external use.
45 unsigned _properly_initialized
;
48 struct merge_options_internal
;
49 struct merge_options
{
50 struct repository
*repo
;
52 /* ref names used in console messages and conflict markers */
57 /* rename related options */
60 MERGE_DIRECTORY_RENAMES_NONE
= 0,
61 MERGE_DIRECTORY_RENAMES_CONFLICT
= 1,
62 MERGE_DIRECTORY_RENAMES_TRUE
= 2
63 } detect_directory_renames
;
66 int show_rename_progress
;
68 /* xdiff-related options (patience, ignore whitespace, ours/theirs) */
72 MERGE_VARIANT_NORMAL
= 0,
77 /* console output related options */
79 unsigned buffer_output
; /* 1: output at end, 2: keep buffered */
80 struct strbuf obuf
; /* output buffer; if buffer_output == 2, caller
81 * must handle and call strbuf_release */
83 /* miscellaneous control options */
84 const char *subtree_shift
;
85 unsigned renormalize
: 1;
86 unsigned mergeability_only
: 1; /* exit early, write fewer objects */
87 unsigned record_conflict_msgs_as_headers
: 1;
88 const char *msg_header_prefix
;
90 /* internal fields used by the implementation */
91 struct merge_options_internal
*priv
;
94 /* Mostly internal function also used by merge-ort-wrappers.c */
95 struct commit
*make_virtual_commit(struct repository
*repo
,
100 * rename-detecting three-way merge with recursive ancestor consolidation.
101 * working tree and index are untouched.
103 * merge_bases will be consumed (emptied) so make a copy if you need it.
105 * NOTE: empirically, the recursive algorithm will perform better if you
106 * pass the merge_bases in the order of oldest commit to the
109 * [1] https://lore.kernel.org/git/nycvar.QRO.7.76.6.1907252055500.21907@tvgsbejvaqbjf.bet/
110 * [2] commit 8918b0c9c2 ("merge-recur: try to merge older merge bases
111 * first", 2006-08-09)
113 void merge_incore_recursive(struct merge_options
*opt
,
114 const struct commit_list
*merge_bases
,
115 struct commit
*side1
,
116 struct commit
*side2
,
117 struct merge_result
*result
);
120 * rename-detecting three-way merge, no recursion.
121 * working tree and index are untouched.
123 void merge_incore_nonrecursive(struct merge_options
*opt
,
124 struct tree
*merge_base
,
127 struct merge_result
*result
);
129 /* Update the working tree and index from head to result after incore merge */
130 void merge_switch_to_result(struct merge_options
*opt
,
132 struct merge_result
*result
,
133 int update_worktree_and_index
,
134 int display_update_msgs
);
137 * Display messages about conflicts and which files were 3-way merged.
138 * Automatically called by merge_switch_to_result() with stream == stdout,
139 * so only call this when bypassing merge_switch_to_result().
141 void merge_display_update_messages(struct merge_options
*opt
,
143 struct merge_result
*result
);
146 struct object_id oid
;
152 * Provide a list of path -> {struct stage_info*} mappings for
153 * all conflicted files. Note that each path could appear up to three
154 * times in the list, corresponding to 3 different stage entries. In short,
155 * this basically provides the info that would be printed by `ls-files -u`.
157 * result should have been populated by a call to
158 * one of the merge_incore_[non]recursive() functions.
160 * conflicted_files should be empty before calling this function.
162 void merge_get_conflicted_files(struct merge_result
*result
,
163 struct string_list
*conflicted_files
);
165 /* Do needed cleanup when not calling merge_switch_to_result() */
166 void merge_finalize(struct merge_options
*opt
,
167 struct merge_result
*result
);
170 /* for use by porcelain commands */
171 void init_ui_merge_options(struct merge_options
*opt
, struct repository
*repo
);
172 /* for use by plumbing commands */
173 void init_basic_merge_options(struct merge_options
*opt
, struct repository
*repo
);
175 void copy_merge_options(struct merge_options
*dst
, struct merge_options
*src
);
176 void clear_merge_options(struct merge_options
*opt
);
178 /* parse the option in s and update the relevant field of opt */
179 int parse_merge_opt(struct merge_options
*opt
, const char *s
);