]> git.ipfire.org Git - thirdparty/git.git/blame - merge-recursive.h
merge-recursive: rename merge_options argument to opt in header
[thirdparty/git.git] / merge-recursive.h
CommitLineData
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
7struct commit;
696ee23c 8
0d6caa2d
NTND
9struct repository;
10
8a2fce18 11struct 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;
85b46030
BP
30 int diff_detect_rename;
31 int merge_detect_rename;
8a2fce18
MV
32 int diff_rename_limit;
33 int merge_rename_limit;
10ae7526 34 int rename_score;
bf0ab10f 35 int needed_rename_limit;
99bfc669 36 int show_rename_progress;
5033639c 37 int call_depth;
c7d84924 38 struct strbuf obuf;
fc65b00d 39 struct hashmap current_file_dir_set;
70cc3d36 40 struct string_list df_conflict_file_set;
64b1abe9 41 struct unpack_trees_options unpack_opts;
a35edc84 42 struct index_state orig_index;
0d6caa2d 43 struct repository *repo;
ea625cb0
EN
44};
45
7fe40b88
EN
46/*
47 * For dir_rename_entry, directory names are stored as a full path from the
48 * toplevel of the repository and do not include a trailing '/'. Also:
49 *
50 * dir: original name of directory being renamed
51 * non_unique_new_dir: if true, could not determine new_dir
52 * new_dir: final name of directory being renamed
53 * possible_new_dirs: temporary used to help determine new_dir; see comments
54 * in get_directory_renames() for details
55 */
56struct dir_rename_entry {
57 struct hashmap_entry ent; /* must be the first member! */
58 char *dir;
59 unsigned non_unique_new_dir:1;
60 struct strbuf new_dir;
61 struct string_list possible_new_dirs;
62};
63
e95ab70a
EN
64struct collision_entry {
65 struct hashmap_entry ent; /* must be the first member! */
66 char *target_file;
67 struct string_list source_files;
68 unsigned reported_already:1;
69};
70
c749ab1d 71static inline int merge_detect_rename(struct merge_options *opt)
85b46030 72{
c749ab1d
EN
73 return opt->merge_detect_rename >= 0 ? opt->merge_detect_rename :
74 opt->diff_detect_rename >= 0 ? opt->diff_detect_rename : 1;
85b46030
BP
75}
76
b4db8a2b
EN
77/*
78 * merge_recursive is like merge_trees() but with recursive ancestor
79 * consolidation, and when successful, it creates an actual commit
80 * and writes its address to *result.
81 *
82 * NOTE: empirically, about a decade ago it was determined that with more
83 * than two merge bases, optimal behavior was found when the
ff1bfa2c
EN
84 * merge_bases were passed in the order of oldest commit to newest
85 * commit. Also, merge_bases will be consumed (emptied) so make a
86 * copy if you need it.
b4db8a2b 87 */
c749ab1d 88int merge_recursive(struct merge_options *opt,
8a2fce18 89 struct commit *h1,
e1b3a2ca 90 struct commit *h2,
ff1bfa2c 91 struct commit_list *merge_bases,
e1b3a2ca
DB
92 struct commit **result);
93
b4db8a2b
EN
94/*
95 * rename-detecting three-way merge, no recursion; result of merge is written
96 * to opt->repo->index.
97 */
c749ab1d 98int merge_trees(struct merge_options *opt,
8a2fce18 99 struct tree *head,
e1b3a2ca 100 struct tree *merge,
ff1bfa2c 101 struct tree *merge_base);
e1b3a2ca 102
8a2fce18
MV
103/*
104 * "git-merge-recursive" can be fed trees; wrap them into
105 * virtual commits and call merge_recursive() proper.
106 */
c749ab1d 107int 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
c749ab1d 114void init_merge_options(struct merge_options *opt,
0d6caa2d 115 struct repository *repo);
9047ebbc 116
c749ab1d 117int parse_merge_opt(struct merge_options *opt, const char *s);
635a7bb1 118
e1b3a2ca 119#endif