]>
Commit | Line | Data |
---|---|---|
e1b3a2ca DB |
1 | #ifndef MERGE_RECURSIVE_H |
2 | #define MERGE_RECURSIVE_H | |
3 | ||
5bf7e577 | 4 | #include "strbuf.h" |
ef3ca954 EN |
5 | |
6 | struct commit; | |
5bf7e577 EN |
7 | struct commit_list; |
8 | struct object_id; | |
0d6caa2d | 9 | struct repository; |
5bf7e577 | 10 | struct tree; |
0d6caa2d | 11 | |
5bf7e577 | 12 | struct merge_options_internal; |
8a2fce18 | 13 | struct merge_options { |
a779fb82 EN |
14 | struct repository *repo; |
15 | ||
16 | /* ref names used in console messages and conflict markers */ | |
4c5868f4 | 17 | const char *ancestor; |
8a2fce18 MV |
18 | const char *branch1; |
19 | const char *branch2; | |
a779fb82 EN |
20 | |
21 | /* rename related options */ | |
22 | int detect_renames; | |
8e012516 DS |
23 | enum { |
24 | MERGE_DIRECTORY_RENAMES_NONE = 0, | |
25 | MERGE_DIRECTORY_RENAMES_CONFLICT = 1, | |
26 | MERGE_DIRECTORY_RENAMES_TRUE = 2 | |
27 | } detect_directory_renames; | |
8599ab45 | 28 | int rename_limit; |
10ae7526 | 29 | int rename_score; |
99bfc669 | 30 | int show_rename_progress; |
a779fb82 EN |
31 | |
32 | /* xdiff-related options (patience, ignore whitespace, ours/theirs) */ | |
33 | long xdl_opts; | |
34 | enum { | |
f3081dae EN |
35 | MERGE_VARIANT_NORMAL = 0, |
36 | MERGE_VARIANT_OURS, | |
37 | MERGE_VARIANT_THEIRS | |
a779fb82 EN |
38 | } recursive_variant; |
39 | ||
40 | /* console output related options */ | |
41 | int verbosity; | |
42 | unsigned buffer_output; /* 1: output at end, 2: keep buffered */ | |
e95e481f EN |
43 | struct strbuf obuf; /* output buffer; if buffer_output == 2, caller |
44 | * must handle and call strbuf_release */ | |
a779fb82 EN |
45 | |
46 | /* miscellaneous control options */ | |
47 | const char *subtree_shift; | |
48 | unsigned renormalize : 1; | |
6054d1aa EN |
49 | unsigned record_conflict_msgs_as_headers : 1; |
50 | const char *msg_header_prefix; | |
a779fb82 | 51 | |
5bf7e577 EN |
52 | /* internal fields used by the implementation */ |
53 | struct merge_options_internal *priv; | |
ea625cb0 EN |
54 | }; |
55 | ||
7c0a6c8e EN |
56 | void init_merge_options(struct merge_options *opt, struct repository *repo); |
57 | ||
b182658e JH |
58 | void copy_merge_options(struct merge_options *dst, struct merge_options *src); |
59 | void clear_merge_options(struct merge_options *opt); | |
60 | ||
7c0a6c8e EN |
61 | /* parse the option in s and update the relevant field of opt */ |
62 | int parse_merge_opt(struct merge_options *opt, const char *s); | |
63 | ||
7fe40b88 | 64 | /* |
7c0a6c8e EN |
65 | * RETURN VALUES: All the merge_* functions below return a value as follows: |
66 | * > 0 Merge was clean | |
67 | * = 0 Merge had conflicts | |
68 | * < 0 Merge hit an unexpected and unrecoverable problem (e.g. disk | |
69 | * full) and aborted merge part-way through. | |
7fe40b88 | 70 | */ |
e95ab70a | 71 | |
7c0a6c8e EN |
72 | /* |
73 | * rename-detecting three-way merge, no recursion. | |
74 | * | |
75 | * Outputs: | |
76 | * - See RETURN VALUES above | |
7c0a6c8e | 77 | * - opt->repo->index has the new index |
56e74342 | 78 | * - new index NOT written to disk |
7c0a6c8e EN |
79 | * - The working tree is updated with results of the merge |
80 | */ | |
81 | int merge_trees(struct merge_options *opt, | |
82 | struct tree *head, | |
83 | struct tree *merge, | |
84 | struct tree *merge_base); | |
85b46030 | 85 | |
b4db8a2b EN |
86 | /* |
87 | * merge_recursive is like merge_trees() but with recursive ancestor | |
56e74342 | 88 | * consolidation. |
b4db8a2b EN |
89 | * |
90 | * NOTE: empirically, about a decade ago it was determined that with more | |
91 | * than two merge bases, optimal behavior was found when the | |
ff1bfa2c EN |
92 | * merge_bases were passed in the order of oldest commit to newest |
93 | * commit. Also, merge_bases will be consumed (emptied) so make a | |
94 | * copy if you need it. | |
7c0a6c8e EN |
95 | * |
96 | * Outputs: | |
97 | * - See RETURN VALUES above | |
56e74342 | 98 | * - *result is treated as scratch space for temporary recursive merges |
7c0a6c8e | 99 | * - opt->repo->index has the new index |
56e74342 | 100 | * - new index NOT written to disk |
7c0a6c8e | 101 | * - The working tree is updated with results of the merge |
b4db8a2b | 102 | */ |
c749ab1d | 103 | int merge_recursive(struct merge_options *opt, |
8a2fce18 | 104 | struct commit *h1, |
e1b3a2ca | 105 | struct commit *h2, |
ff1bfa2c | 106 | struct commit_list *merge_bases, |
e1b3a2ca DB |
107 | struct commit **result); |
108 | ||
b4db8a2b | 109 | /* |
7c0a6c8e EN |
110 | * merge_recursive_generic can operate on trees instead of commits, by |
111 | * wrapping the trees into virtual commits, and calling merge_recursive(). | |
112 | * It also writes out the in-memory index to disk if the merge is successful. | |
113 | * | |
114 | * Outputs: | |
115 | * - See RETURN VALUES above | |
56e74342 | 116 | * - *result is treated as scratch space for temporary recursive merges |
7c0a6c8e | 117 | * - opt->repo->index has the new index |
56e74342 | 118 | * - new index also written to $GIT_INDEX_FILE on disk |
7c0a6c8e | 119 | * - The working tree is updated with results of the merge |
8a2fce18 | 120 | */ |
c749ab1d | 121 | int merge_recursive_generic(struct merge_options *opt, |
4e8161a8 | 122 | const struct object_id *head, |
123 | const struct object_id *merge, | |
ff1bfa2c EN |
124 | int num_merge_bases, |
125 | const struct object_id **merge_bases, | |
8a2fce18 MV |
126 | struct commit **result); |
127 | ||
e1b3a2ca | 128 | #endif |