merge-recursive: add computation of collisions due to dir rename & merging
[git] / merge-recursive.h
1 #ifndef MERGE_RECURSIVE_H
2 #define MERGE_RECURSIVE_H
3
4 #include "string-list.h"
5
6 struct merge_options {
7         const char *ancestor;
8         const char *branch1;
9         const char *branch2;
10         enum {
11                 MERGE_RECURSIVE_NORMAL = 0,
12                 MERGE_RECURSIVE_OURS,
13                 MERGE_RECURSIVE_THEIRS
14         } recursive_variant;
15         const char *subtree_shift;
16         unsigned buffer_output; /* 1: output at end, 2: keep buffered */
17         unsigned renormalize : 1;
18         long xdl_opts;
19         int verbosity;
20         int detect_rename;
21         int diff_rename_limit;
22         int merge_rename_limit;
23         int rename_score;
24         int needed_rename_limit;
25         int show_rename_progress;
26         int call_depth;
27         struct strbuf obuf;
28         struct hashmap current_file_dir_set;
29         struct string_list df_conflict_file_set;
30 };
31
32 /*
33  * For dir_rename_entry, directory names are stored as a full path from the
34  * toplevel of the repository and do not include a trailing '/'.  Also:
35  *
36  *   dir:                original name of directory being renamed
37  *   non_unique_new_dir: if true, could not determine new_dir
38  *   new_dir:            final name of directory being renamed
39  *   possible_new_dirs:  temporary used to help determine new_dir; see comments
40  *                       in get_directory_renames() for details
41  */
42 struct dir_rename_entry {
43         struct hashmap_entry ent; /* must be the first member! */
44         char *dir;
45         unsigned non_unique_new_dir:1;
46         struct strbuf new_dir;
47         struct string_list possible_new_dirs;
48 };
49
50 struct collision_entry {
51         struct hashmap_entry ent; /* must be the first member! */
52         char *target_file;
53         struct string_list source_files;
54         unsigned reported_already:1;
55 };
56
57 /* merge_trees() but with recursive ancestor consolidation */
58 int merge_recursive(struct merge_options *o,
59                     struct commit *h1,
60                     struct commit *h2,
61                     struct commit_list *ancestors,
62                     struct commit **result);
63
64 /* rename-detecting three-way merge, no recursion */
65 int merge_trees(struct merge_options *o,
66                 struct tree *head,
67                 struct tree *merge,
68                 struct tree *common,
69                 struct tree **result);
70
71 /*
72  * "git-merge-recursive" can be fed trees; wrap them into
73  * virtual commits and call merge_recursive() proper.
74  */
75 int merge_recursive_generic(struct merge_options *o,
76                             const struct object_id *head,
77                             const struct object_id *merge,
78                             int num_ca,
79                             const struct object_id **ca,
80                             struct commit **result);
81
82 void init_merge_options(struct merge_options *o);
83 struct tree *write_tree_from_memory(struct merge_options *o);
84
85 int parse_merge_opt(struct merge_options *out, const char *s);
86
87 #endif