1 #ifndef MERGE_ORT_H
2 #define MERGE_ORT_H
3 
4 #include "merge-recursive.h"
5 
6 struct commit;
7 struct tree;
8 
9 struct merge_result {
10 	/*
11 	 * Whether the merge is clean; possible values:
12 	 *    1: clean
13 	 *    0: not clean (merge conflicts)
14 	 *   <0: operation aborted prematurely.  (object database
15 	 *       unreadable, disk full, etc.)  Worktree may be left in an
16 	 *       inconsistent state if operation failed near the end.
17 	 */
18 	int clean;
19 
20 	/*
21 	 * Result of merge.  If !clean, represents what would go in worktree
22 	 * (thus possibly including files containing conflict markers).
23 	 */
24 	struct tree *tree;
25 
26 	/*
27 	 * Additional metadata used by merge_switch_to_result() or future calls
28 	 * to merge_incore_*().  Includes data needed to update the index (if
29 	 * !clean) and to print "CONFLICT" messages.  Not for external use.
30 	 */
31 	void *priv;
32 	/* Also private */
33 	unsigned _properly_initialized;
34 };
35 
36 /*
37  * rename-detecting three-way merge with recursive ancestor consolidation.
38  * working tree and index are untouched.
39  *
40  * merge_bases will be consumed (emptied) so make a copy if you need it.
41  *
42  * NOTE: empirically, the recursive algorithm will perform better if you
43  *       pass the merge_bases in the order of oldest commit to the
44  *       newest[1][2].
45  *
46  *       [1] https://lore.kernel.org/git/nycvar.QRO.7.76.6.1907252055500.21907@tvgsbejvaqbjf.bet/
47  *       [2] commit 8918b0c9c2 ("merge-recur: try to merge older merge bases
48  *           first", 2006-08-09)
49  */
50 void merge_incore_recursive(struct merge_options *opt,
51 			    struct commit_list *merge_bases,
52 			    struct commit *side1,
53 			    struct commit *side2,
54 			    struct merge_result *result);
55 
56 /*
57  * rename-detecting three-way merge, no recursion.
58  * working tree and index are untouched.
59  */
60 void merge_incore_nonrecursive(struct merge_options *opt,
61 			       struct tree *merge_base,
62 			       struct tree *side1,
63 			       struct tree *side2,
64 			       struct merge_result *result);
65 
66 /* Update the working tree and index from head to result after incore merge */
67 void merge_switch_to_result(struct merge_options *opt,
68 			    struct tree *head,
69 			    struct merge_result *result,
70 			    int update_worktree_and_index,
71 			    int display_update_msgs);
72 
73 /* Do needed cleanup when not calling merge_switch_to_result() */
74 void merge_finalize(struct merge_options *opt,
75 		    struct merge_result *result);
76 
77 #endif
78