merge-ort/merge-recursive: do report errors in `merge_submodule()`
[git/gitster.git] / unpack-trees.h
blob5867e26e17777483f3fc5df0084deb7a4dd135da
1 #ifndef UNPACK_TREES_H
2 #define UNPACK_TREES_H
4 #include "convert.h"
5 #include "read-cache-ll.h"
6 #include "strvec.h"
7 #include "string-list.h"
8 #include "tree-walk.h"
10 #define MAX_UNPACK_TREES 8
12 struct cache_entry;
13 struct unpack_trees_options;
14 struct pattern_list;
16 typedef int (*merge_fn_t)(const struct cache_entry * const *src,
17 struct unpack_trees_options *options);
19 enum unpack_trees_error_types {
20 ERROR_WOULD_OVERWRITE = 0,
21 ERROR_NOT_UPTODATE_FILE,
22 ERROR_NOT_UPTODATE_DIR,
23 ERROR_CWD_IN_THE_WAY,
24 ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
25 ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
26 ERROR_BIND_OVERLAP,
27 ERROR_WOULD_LOSE_SUBMODULE,
29 NB_UNPACK_TREES_ERROR_TYPES,
31 WARNING_SPARSE_NOT_UPTODATE_FILE,
32 WARNING_SPARSE_UNMERGED_FILE,
33 WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN,
35 NB_UNPACK_TREES_WARNING_TYPES,
39 * Sets the list of user-friendly error messages to be used by the
40 * command "cmd" (either merge or checkout), and show_all_errors to 1.
42 void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
43 const char *cmd);
46 * Frees resources allocated by setup_unpack_trees_porcelain().
48 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
50 enum unpack_trees_reset_type {
51 UNPACK_RESET_NONE = 0, /* traditional "false" value; still valid */
52 UNPACK_RESET_INVALID = 1, /* "true" no longer valid; use below values */
53 UNPACK_RESET_PROTECT_UNTRACKED,
54 UNPACK_RESET_OVERWRITE_UNTRACKED
57 struct unpack_trees_options {
58 unsigned int merge,
59 update,
60 preserve_ignored,
61 clone,
62 index_only,
63 trivial_merges_only,
64 verbose_update,
65 aggressive,
66 skip_unmerged,
67 initial_checkout,
68 diff_index_cached,
69 skip_sparse_checkout,
70 quiet,
71 exiting_early,
72 dry_run,
73 skip_cache_tree_update;
74 enum unpack_trees_reset_type reset;
75 const char *prefix;
76 const char *super_prefix;
77 struct pathspec *pathspec;
78 merge_fn_t fn;
80 int head_idx;
82 struct cache_entry *df_conflict_entry; /* output only */
83 void *unpack_data;
85 struct index_state *dst_index;
86 struct index_state *src_index;
88 struct checkout_metadata meta;
90 struct unpack_trees_options_internal {
91 unsigned int nontrivial_merge,
92 show_all_errors,
93 debug_unpack; /* used by read-tree debugging */
95 int merge_size; /* used by read-tree debugging */
96 int cache_bottom;
97 const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
98 struct strvec msgs_to_free;
101 * Store error messages in an array, each case
102 * corresponding to a error message type
104 struct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES];
106 struct index_state result;
108 struct pattern_list *pl;
109 struct dir_struct *dir;
110 } internal;
113 int unpack_trees(unsigned n, struct tree_desc *t,
114 struct unpack_trees_options *options);
116 enum update_sparsity_result {
117 UPDATE_SPARSITY_SUCCESS = 0,
118 UPDATE_SPARSITY_WARNINGS = 1,
119 UPDATE_SPARSITY_INDEX_UPDATE_FAILURES = -1,
120 UPDATE_SPARSITY_WORKTREE_UPDATE_FAILURES = -2
123 enum update_sparsity_result update_sparsity(struct unpack_trees_options *options,
124 struct pattern_list *pl);
126 int verify_uptodate(const struct cache_entry *ce,
127 struct unpack_trees_options *o);
129 int threeway_merge(const struct cache_entry * const *stages,
130 struct unpack_trees_options *o);
131 int twoway_merge(const struct cache_entry * const *src,
132 struct unpack_trees_options *o);
133 int bind_merge(const struct cache_entry * const *src,
134 struct unpack_trees_options *o);
135 int oneway_merge(const struct cache_entry * const *src,
136 struct unpack_trees_options *o);
137 int stash_worktree_untracked_merge(const struct cache_entry * const *src,
138 struct unpack_trees_options *o);
140 #endif