]>
Commit | Line | Data |
---|---|---|
e1b3a2ca DB |
1 | #ifndef MERGE_RECURSIVE_H |
2 | #define MERGE_RECURSIVE_H | |
3 | ||
696ee23c | 4 | #include "string-list.h" |
ef3ca954 EN |
5 | #include "unpack-trees.h" |
6 | ||
7 | struct commit; | |
696ee23c | 8 | |
0d6caa2d NTND |
9 | struct repository; |
10 | ||
8a2fce18 | 11 | struct merge_options { |
4c5868f4 | 12 | const char *ancestor; |
8a2fce18 MV |
13 | const char *branch1; |
14 | const char *branch2; | |
8cc5b290 | 15 | enum { |
85e51b78 | 16 | MERGE_RECURSIVE_NORMAL = 0, |
8cc5b290 | 17 | MERGE_RECURSIVE_OURS, |
4b05548f | 18 | MERGE_RECURSIVE_THEIRS |
8cc5b290 | 19 | } recursive_variant; |
85e51b78 | 20 | const char *subtree_shift; |
f1e2426b | 21 | unsigned buffer_output; /* 1: output at end, 2: keep buffered */ |
1bc0ab7c | 22 | unsigned renormalize : 1; |
58a1ece4 | 23 | long xdl_opts; |
8a2fce18 | 24 | int verbosity; |
8e012516 DS |
25 | enum { |
26 | MERGE_DIRECTORY_RENAMES_NONE = 0, | |
27 | MERGE_DIRECTORY_RENAMES_CONFLICT = 1, | |
28 | MERGE_DIRECTORY_RENAMES_TRUE = 2 | |
29 | } detect_directory_renames; | |
8599ab45 EN |
30 | int detect_renames; |
31 | int rename_limit; | |
10ae7526 | 32 | int rename_score; |
bf0ab10f | 33 | int needed_rename_limit; |
99bfc669 | 34 | int show_rename_progress; |
5033639c | 35 | int call_depth; |
c7d84924 | 36 | struct strbuf obuf; |
fc65b00d | 37 | struct hashmap current_file_dir_set; |
70cc3d36 | 38 | struct string_list df_conflict_file_set; |
64b1abe9 | 39 | struct unpack_trees_options unpack_opts; |
a35edc84 | 40 | struct index_state orig_index; |
0d6caa2d | 41 | struct repository *repo; |
ea625cb0 EN |
42 | }; |
43 | ||
7c0a6c8e EN |
44 | void init_merge_options(struct merge_options *opt, struct repository *repo); |
45 | ||
46 | /* parse the option in s and update the relevant field of opt */ | |
47 | int parse_merge_opt(struct merge_options *opt, const char *s); | |
48 | ||
7fe40b88 | 49 | /* |
7c0a6c8e EN |
50 | * RETURN VALUES: All the merge_* functions below return a value as follows: |
51 | * > 0 Merge was clean | |
52 | * = 0 Merge had conflicts | |
53 | * < 0 Merge hit an unexpected and unrecoverable problem (e.g. disk | |
54 | * full) and aborted merge part-way through. | |
7fe40b88 | 55 | */ |
e95ab70a | 56 | |
7c0a6c8e EN |
57 | /* |
58 | * rename-detecting three-way merge, no recursion. | |
59 | * | |
60 | * Outputs: | |
61 | * - See RETURN VALUES above | |
62 | * - No commit is created | |
63 | * - opt->repo->index has the new index | |
64 | * - $GIT_INDEX_FILE is not updated | |
65 | * - The working tree is updated with results of the merge | |
66 | */ | |
67 | int merge_trees(struct merge_options *opt, | |
68 | struct tree *head, | |
69 | struct tree *merge, | |
70 | struct tree *merge_base); | |
85b46030 | 71 | |
b4db8a2b EN |
72 | /* |
73 | * merge_recursive is like merge_trees() but with recursive ancestor | |
7c0a6c8e | 74 | * consolidation and, if the commit is clean, creation of a commit. |
b4db8a2b EN |
75 | * |
76 | * NOTE: empirically, about a decade ago it was determined that with more | |
77 | * than two merge bases, optimal behavior was found when the | |
ff1bfa2c EN |
78 | * merge_bases were passed in the order of oldest commit to newest |
79 | * commit. Also, merge_bases will be consumed (emptied) so make a | |
80 | * copy if you need it. | |
7c0a6c8e EN |
81 | * |
82 | * Outputs: | |
83 | * - See RETURN VALUES above | |
84 | * - If merge is clean, a commit is created and its address written to *result | |
85 | * - opt->repo->index has the new index | |
86 | * - $GIT_INDEX_FILE is not updated | |
87 | * - The working tree is updated with results of the merge | |
b4db8a2b | 88 | */ |
c749ab1d | 89 | int merge_recursive(struct merge_options *opt, |
8a2fce18 | 90 | struct commit *h1, |
e1b3a2ca | 91 | struct commit *h2, |
ff1bfa2c | 92 | struct commit_list *merge_bases, |
e1b3a2ca DB |
93 | struct commit **result); |
94 | ||
b4db8a2b | 95 | /* |
7c0a6c8e EN |
96 | * merge_recursive_generic can operate on trees instead of commits, by |
97 | * wrapping the trees into virtual commits, and calling merge_recursive(). | |
98 | * It also writes out the in-memory index to disk if the merge is successful. | |
99 | * | |
100 | * Outputs: | |
101 | * - See RETURN VALUES above | |
102 | * - If merge is clean, a commit is created and its address written to *result | |
103 | * - opt->repo->index has the new index | |
104 | * - $GIT_INDEX_FILE is updated | |
105 | * - The working tree is updated with results of the merge | |
8a2fce18 | 106 | */ |
c749ab1d | 107 | int merge_recursive_generic(struct merge_options *opt, |
4e8161a8 | 108 | const struct object_id *head, |
109 | const struct object_id *merge, | |
ff1bfa2c EN |
110 | int num_merge_bases, |
111 | const struct object_id **merge_bases, | |
8a2fce18 MV |
112 | struct commit **result); |
113 | ||
e1b3a2ca | 114 | #endif |