]> git.ipfire.org Git - thirdparty/git.git/blob - unpack-trees.h
aac1ad4b014bce2ed9ede8ed3700fc8a54d955de
[thirdparty/git.git] / unpack-trees.h
1 #ifndef UNPACK_TREES_H
2 #define UNPACK_TREES_H
3
4 #include "cache.h"
5 #include "argv-array.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 WARNING_SPARSE_NOT_UPTODATE_FILE,
28 WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN,
29
30 NB_UNPACK_TREES_ERROR_TYPES,
31 };
32
33 /*
34 * Sets the list of user-friendly error messages to be used by the
35 * command "cmd" (either merge or checkout), and show_all_errors to 1.
36 */
37 void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
38 const char *cmd);
39
40 /*
41 * Frees resources allocated by setup_unpack_trees_porcelain().
42 */
43 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
44
45 struct unpack_trees_options {
46 unsigned int reset,
47 merge,
48 update,
49 clone,
50 index_only,
51 nontrivial_merge,
52 trivial_merges_only,
53 verbose_update,
54 aggressive,
55 skip_unmerged,
56 initial_checkout,
57 diff_index_cached,
58 debug_unpack,
59 skip_sparse_checkout,
60 quiet,
61 exiting_early,
62 show_all_errors,
63 dry_run;
64 const char *prefix;
65 int cache_bottom;
66 struct dir_struct *dir;
67 struct pathspec *pathspec;
68 merge_fn_t fn;
69 const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
70 struct argv_array msgs_to_free;
71 /*
72 * Store error messages in an array, each case
73 * corresponding to a error message type
74 */
75 struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
76
77 int head_idx;
78 int merge_size;
79
80 struct cache_entry *df_conflict_entry;
81 void *unpack_data;
82
83 struct index_state *dst_index;
84 struct index_state *src_index;
85 struct index_state result;
86
87 struct pattern_list *pl; /* for internal use */
88 };
89
90 int unpack_trees(unsigned n, struct tree_desc *t,
91 struct unpack_trees_options *options);
92
93 enum update_sparsity_result {
94 UPDATE_SPARSITY_SUCCESS = 0,
95 UPDATE_SPARSITY_WARNINGS = 1,
96 UPDATE_SPARSITY_INDEX_UPDATE_FAILURES = -1,
97 UPDATE_SPARSITY_WORKTREE_UPDATE_FAILURES = -2
98 };
99
100 enum update_sparsity_result update_sparsity(struct unpack_trees_options *options);
101
102 int verify_uptodate(const struct cache_entry *ce,
103 struct unpack_trees_options *o);
104
105 int threeway_merge(const struct cache_entry * const *stages,
106 struct unpack_trees_options *o);
107 int twoway_merge(const struct cache_entry * const *src,
108 struct unpack_trees_options *o);
109 int bind_merge(const struct cache_entry * const *src,
110 struct unpack_trees_options *o);
111 int oneway_merge(const struct cache_entry * const *src,
112 struct unpack_trees_options *o);
113
114 #endif