]> git.ipfire.org Git - thirdparty/git.git/blob - merge-ort.h
Merge branch 'rs/grep-no-no-or'
[thirdparty/git.git] / merge-ort.h
1 #ifndef MERGE_ORT_H
2 #define MERGE_ORT_H
3
4 #include "merge-recursive.h"
5 #include "hash-ll.h"
6
7 struct commit;
8 struct tree;
9 struct strmap;
10
11 struct merge_result {
12 /*
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.
19 */
20 int clean;
21
22 /*
23 * Result of merge. If !clean, represents what would go in worktree
24 * (thus possibly including files containing conflict markers).
25 */
26 struct tree *tree;
27
28 /*
29 * Special messages and conflict notices for various paths
30 *
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.
34 */
35 struct strmap *path_messages;
36
37 /*
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.
41 */
42 void *priv;
43 /* Also private */
44 unsigned _properly_initialized;
45 };
46
47 /*
48 * rename-detecting three-way merge with recursive ancestor consolidation.
49 * working tree and index are untouched.
50 *
51 * merge_bases will be consumed (emptied) so make a copy if you need it.
52 *
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].
56 *
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)
60 */
61 void merge_incore_recursive(struct merge_options *opt,
62 struct commit_list *merge_bases,
63 struct commit *side1,
64 struct commit *side2,
65 struct merge_result *result);
66
67 /*
68 * rename-detecting three-way merge, no recursion.
69 * working tree and index are untouched.
70 */
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);
76
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);
83
84 /*
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().
88 */
89 void merge_display_update_messages(struct merge_options *opt,
90 int detailed,
91 struct merge_result *result);
92
93 struct stage_info {
94 struct object_id oid;
95 int mode;
96 int stage;
97 };
98
99 /*
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`.
104 *
105 * result should have been populated by a call to
106 * one of the merge_incore_[non]recursive() functions.
107 *
108 * conflicted_files should be empty before calling this function.
109 */
110 void merge_get_conflicted_files(struct merge_result *result,
111 struct string_list *conflicted_files);
112
113 /* Do needed cleanup when not calling merge_switch_to_result() */
114 void merge_finalize(struct merge_options *opt,
115 struct merge_result *result);
116
117 #endif