]>
Commit | Line | Data |
---|---|---|
1 | #ifndef MERGE_RECURSIVE_H | |
2 | #define MERGE_RECURSIVE_H | |
3 | ||
4 | #include "strbuf.h" | |
5 | ||
6 | struct commit; | |
7 | struct commit_list; | |
8 | struct object_id; | |
9 | struct repository; | |
10 | struct tree; | |
11 | ||
12 | struct merge_options_internal; | |
13 | struct merge_options { | |
14 | struct repository *repo; | |
15 | ||
16 | /* ref names used in console messages and conflict markers */ | |
17 | const char *ancestor; | |
18 | const char *branch1; | |
19 | const char *branch2; | |
20 | ||
21 | /* rename related options */ | |
22 | int detect_renames; | |
23 | enum { | |
24 | MERGE_DIRECTORY_RENAMES_NONE = 0, | |
25 | MERGE_DIRECTORY_RENAMES_CONFLICT = 1, | |
26 | MERGE_DIRECTORY_RENAMES_TRUE = 2 | |
27 | } detect_directory_renames; | |
28 | int rename_limit; | |
29 | int rename_score; | |
30 | int show_rename_progress; | |
31 | ||
32 | /* xdiff-related options (patience, ignore whitespace, ours/theirs) */ | |
33 | long xdl_opts; | |
34 | enum { | |
35 | MERGE_VARIANT_NORMAL = 0, | |
36 | MERGE_VARIANT_OURS, | |
37 | MERGE_VARIANT_THEIRS | |
38 | } recursive_variant; | |
39 | ||
40 | /* console output related options */ | |
41 | int verbosity; | |
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 */ | |
45 | ||
46 | /* miscellaneous control options */ | |
47 | const char *subtree_shift; | |
48 | unsigned renormalize : 1; | |
49 | ||
50 | /* internal fields used by the implementation */ | |
51 | struct merge_options_internal *priv; | |
52 | }; | |
53 | ||
54 | void init_merge_options(struct merge_options *opt, struct repository *repo); | |
55 | ||
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); | |
58 | ||
59 | /* | |
60 | * RETURN VALUES: All the merge_* functions below return a value as follows: | |
61 | * > 0 Merge was clean | |
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. | |
65 | */ | |
66 | ||
67 | /* | |
68 | * rename-detecting three-way merge, no recursion. | |
69 | * | |
70 | * Outputs: | |
71 | * - See RETURN VALUES above | |
72 | * - opt->repo->index has the new index | |
73 | * - new index NOT written to disk | |
74 | * - The working tree is updated with results of the merge | |
75 | */ | |
76 | int merge_trees(struct merge_options *opt, | |
77 | struct tree *head, | |
78 | struct tree *merge, | |
79 | struct tree *merge_base); | |
80 | ||
81 | /* | |
82 | * merge_recursive is like merge_trees() but with recursive ancestor | |
83 | * consolidation. | |
84 | * | |
85 | * NOTE: empirically, about a decade ago it was determined that with more | |
86 | * than two merge bases, optimal behavior was found when the | |
87 | * merge_bases were passed in the order of oldest commit to newest | |
88 | * commit. Also, merge_bases will be consumed (emptied) so make a | |
89 | * copy if you need it. | |
90 | * | |
91 | * Outputs: | |
92 | * - See RETURN VALUES above | |
93 | * - *result is treated as scratch space for temporary recursive merges | |
94 | * - opt->repo->index has the new index | |
95 | * - new index NOT written to disk | |
96 | * - The working tree is updated with results of the merge | |
97 | */ | |
98 | int merge_recursive(struct merge_options *opt, | |
99 | struct commit *h1, | |
100 | struct commit *h2, | |
101 | struct commit_list *merge_bases, | |
102 | struct commit **result); | |
103 | ||
104 | /* | |
105 | * merge_recursive_generic can operate on trees instead of commits, by | |
106 | * wrapping the trees into virtual commits, and calling merge_recursive(). | |
107 | * It also writes out the in-memory index to disk if the merge is successful. | |
108 | * | |
109 | * Outputs: | |
110 | * - See RETURN VALUES above | |
111 | * - *result is treated as scratch space for temporary recursive merges | |
112 | * - opt->repo->index has the new index | |
113 | * - new index also written to $GIT_INDEX_FILE on disk | |
114 | * - The working tree is updated with results of the merge | |
115 | */ | |
116 | int merge_recursive_generic(struct merge_options *opt, | |
117 | const struct object_id *head, | |
118 | const struct object_id *merge, | |
119 | int num_merge_bases, | |
120 | const struct object_id **merge_bases, | |
121 | struct commit **result); | |
122 | ||
123 | #endif |