Merge branch 'ak/doc-sparse-co-typofix'
[git/gitster.git] / merge-ort.h
blob82f2b3222d2fbe93a18e24f1e63149a54834ae28
1 #ifndef MERGE_ORT_H
2 #define MERGE_ORT_H
4 #include "merge-recursive.h"
5 #include "hash.h"
7 struct commit;
8 struct tree;
9 struct strmap;
11 struct merge_result {
13 * Whether the merge is clean; possible values:
14 * 1: clean
15 * 0: not clean (merge conflicts)
16 * <0: operation aborted prematurely. (object database
17 * unreadable, disk full, etc.) Worktree may be left in an
18 * inconsistent state if operation failed near the end.
20 int clean;
23 * Result of merge. If !clean, represents what would go in worktree
24 * (thus possibly including files containing conflict markers).
26 struct tree *tree;
29 * Special messages and conflict notices for various paths
31 * This is a map of pathnames to a string_list. It contains various
32 * warning/conflict/notice messages (possibly multiple per path)
33 * that callers may want to use.
35 struct strmap *path_messages;
38 * Additional metadata used by merge_switch_to_result() or future calls
39 * to merge_incore_*(). Includes data needed to update the index (if
40 * !clean) and to print "CONFLICT" messages. Not for external use.
42 void *priv;
43 /* Also private */
44 unsigned _properly_initialized;
48 * rename-detecting three-way merge with recursive ancestor consolidation.
49 * working tree and index are untouched.
51 * merge_bases will be consumed (emptied) so make a copy if you need it.
53 * NOTE: empirically, the recursive algorithm will perform better if you
54 * pass the merge_bases in the order of oldest commit to the
55 * newest[1][2].
57 * [1] https://lore.kernel.org/git/nycvar.QRO.7.76.6.1907252055500.21907@tvgsbejvaqbjf.bet/
58 * [2] commit 8918b0c9c2 ("merge-recur: try to merge older merge bases
59 * first", 2006-08-09)
61 void merge_incore_recursive(struct merge_options *opt,
62 const struct commit_list *merge_bases,
63 struct commit *side1,
64 struct commit *side2,
65 struct merge_result *result);
68 * rename-detecting three-way merge, no recursion.
69 * working tree and index are untouched.
71 void merge_incore_nonrecursive(struct merge_options *opt,
72 struct tree *merge_base,
73 struct tree *side1,
74 struct tree *side2,
75 struct merge_result *result);
77 /* Update the working tree and index from head to result after incore merge */
78 void merge_switch_to_result(struct merge_options *opt,
79 struct tree *head,
80 struct merge_result *result,
81 int update_worktree_and_index,
82 int display_update_msgs);
85 * Display messages about conflicts and which files were 3-way merged.
86 * Automatically called by merge_switch_to_result() with stream == stdout,
87 * so only call this when bypassing merge_switch_to_result().
89 void merge_display_update_messages(struct merge_options *opt,
90 int detailed,
91 struct merge_result *result);
93 struct stage_info {
94 struct object_id oid;
95 int mode;
96 int stage;
100 * Provide a list of path -> {struct stage_info*} mappings for
101 * all conflicted files. Note that each path could appear up to three
102 * times in the list, corresponding to 3 different stage entries. In short,
103 * this basically provides the info that would be printed by `ls-files -u`.
105 * result should have been populated by a call to
106 * one of the merge_incore_[non]recursive() functions.
108 * conflicted_files should be empty before calling this function.
110 void merge_get_conflicted_files(struct merge_result *result,
111 struct string_list *conflicted_files);
113 /* Do needed cleanup when not calling merge_switch_to_result() */
114 void merge_finalize(struct merge_options *opt,
115 struct merge_result *result);
117 #endif