]> git.ipfire.org Git - thirdparty/git.git/blob - unpack-trees.h
reftable: fix resource warning
[thirdparty/git.git] / unpack-trees.h
1 #ifndef UNPACK_TREES_H
2 #define UNPACK_TREES_H
3
4 #include "cache.h"
5 #include "strvec.h"
6 #include "string-list.h"
7 #include "tree-walk.h"
8
9 #define MAX_UNPACK_TREES MAX_TRAVERSE_TREES
10
11 struct cache_entry;
12 struct unpack_trees_options;
13 struct pattern_list;
14
15 typedef int (*merge_fn_t)(const struct cache_entry * const *src,
16 struct unpack_trees_options *options);
17
18 enum unpack_trees_error_types {
19 ERROR_WOULD_OVERWRITE = 0,
20 ERROR_NOT_UPTODATE_FILE,
21 ERROR_NOT_UPTODATE_DIR,
22 ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
23 ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
24 ERROR_BIND_OVERLAP,
25 ERROR_WOULD_LOSE_SUBMODULE,
26
27 NB_UNPACK_TREES_ERROR_TYPES,
28
29 WARNING_SPARSE_NOT_UPTODATE_FILE,
30 WARNING_SPARSE_UNMERGED_FILE,
31 WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN,
32
33 NB_UNPACK_TREES_WARNING_TYPES,
34 };
35
36 /*
37 * Sets the list of user-friendly error messages to be used by the
38 * command "cmd" (either merge or checkout), and show_all_errors to 1.
39 */
40 void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
41 const char *cmd);
42
43 /*
44 * Frees resources allocated by setup_unpack_trees_porcelain().
45 */
46 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
47
48 enum unpack_trees_reset_type {
49 UNPACK_RESET_NONE = 0, /* traditional "false" value; still valid */
50 UNPACK_RESET_INVALID = 1, /* "true" no longer valid; use below values */
51 UNPACK_RESET_PROTECT_UNTRACKED,
52 UNPACK_RESET_OVERWRITE_UNTRACKED
53 };
54
55 struct unpack_trees_options {
56 unsigned int merge,
57 update,
58 preserve_ignored,
59 clone,
60 index_only,
61 nontrivial_merge,
62 trivial_merges_only,
63 verbose_update,
64 aggressive,
65 skip_unmerged,
66 initial_checkout,
67 diff_index_cached,
68 debug_unpack,
69 skip_sparse_checkout,
70 quiet,
71 exiting_early,
72 show_all_errors,
73 dry_run;
74 enum unpack_trees_reset_type reset;
75 const char *prefix;
76 int cache_bottom;
77 struct pathspec *pathspec;
78 merge_fn_t fn;
79 const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
80 struct strvec msgs_to_free;
81 /*
82 * Store error messages in an array, each case
83 * corresponding to a error message type
84 */
85 struct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES];
86
87 int head_idx;
88 int merge_size;
89
90 struct cache_entry *df_conflict_entry;
91 void *unpack_data;
92
93 struct index_state *dst_index;
94 struct index_state *src_index;
95 struct index_state result;
96
97 struct pattern_list *pl; /* for internal use */
98 struct dir_struct *dir; /* for internal use only */
99 struct checkout_metadata meta;
100 };
101
102 int unpack_trees(unsigned n, struct tree_desc *t,
103 struct unpack_trees_options *options);
104
105 enum update_sparsity_result {
106 UPDATE_SPARSITY_SUCCESS = 0,
107 UPDATE_SPARSITY_WARNINGS = 1,
108 UPDATE_SPARSITY_INDEX_UPDATE_FAILURES = -1,
109 UPDATE_SPARSITY_WORKTREE_UPDATE_FAILURES = -2
110 };
111
112 enum update_sparsity_result update_sparsity(struct unpack_trees_options *options);
113
114 int verify_uptodate(const struct cache_entry *ce,
115 struct unpack_trees_options *o);
116
117 int threeway_merge(const struct cache_entry * const *stages,
118 struct unpack_trees_options *o);
119 int twoway_merge(const struct cache_entry * const *src,
120 struct unpack_trees_options *o);
121 int bind_merge(const struct cache_entry * const *src,
122 struct unpack_trees_options *o);
123 int oneway_merge(const struct cache_entry * const *src,
124 struct unpack_trees_options *o);
125 int stash_worktree_untracked_merge(const struct cache_entry * const *src,
126 struct unpack_trees_options *o);
127
128 #endif