]>
Commit | Line | Data |
---|---|---|
16da134b JS |
1 | #ifndef UNPACK_TREES_H |
2 | #define UNPACK_TREES_H | |
3 | ||
73359a9b | 4 | #include "convert.h" |
08c46a49 | 5 | #include "read-cache-ll.h" |
dbbcd44f | 6 | #include "strvec.h" |
ef3ca954 EN |
7 | #include "string-list.h" |
8 | #include "tree-walk.h" | |
7980872d | 9 | |
acd13d1e | 10 | #define MAX_UNPACK_TREES 8 |
ca885a4f | 11 | |
ef3ca954 | 12 | struct cache_entry; |
16da134b | 13 | struct unpack_trees_options; |
caa3d554 | 14 | struct pattern_list; |
16da134b | 15 | |
5828e835 | 16 | typedef int (*merge_fn_t)(const struct cache_entry * const *src, |
34110cd4 | 17 | struct unpack_trees_options *options); |
16da134b | 18 | |
08353ebb MM |
19 | enum unpack_trees_error_types { |
20 | ERROR_WOULD_OVERWRITE = 0, | |
21 | ERROR_NOT_UPTODATE_FILE, | |
22 | ERROR_NOT_UPTODATE_DIR, | |
b817e545 | 23 | ERROR_CWD_IN_THE_WAY, |
08402b04 MM |
24 | ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, |
25 | ERROR_WOULD_LOSE_UNTRACKED_REMOVED, | |
08353ebb | 26 | ERROR_BIND_OVERLAP, |
a7bc845a | 27 | ERROR_WOULD_LOSE_SUBMODULE, |
1ac83f42 | 28 | |
6271d77c EN |
29 | NB_UNPACK_TREES_ERROR_TYPES, |
30 | ||
1ac83f42 | 31 | WARNING_SPARSE_NOT_UPTODATE_FILE, |
ebb568b9 | 32 | WARNING_SPARSE_UNMERGED_FILE, |
1ac83f42 EN |
33 | WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN, |
34 | ||
6271d77c | 35 | NB_UNPACK_TREES_WARNING_TYPES, |
8ccba008 JH |
36 | }; |
37 | ||
dc1166e6 MM |
38 | /* |
39 | * Sets the list of user-friendly error messages to be used by the | |
5e65ee35 | 40 | * command "cmd" (either merge or checkout), and show_all_errors to 1. |
dc1166e6 | 41 | */ |
e294030f MM |
42 | void setup_unpack_trees_porcelain(struct unpack_trees_options *opts, |
43 | const char *cmd); | |
dc1166e6 | 44 | |
1c41d280 MÅ |
45 | /* |
46 | * Frees resources allocated by setup_unpack_trees_porcelain(). | |
47 | */ | |
48 | void clear_unpack_trees_porcelain(struct unpack_trees_options *opts); | |
49 | ||
480d3d6b EN |
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 | |
55 | }; | |
56 | ||
16da134b | 57 | struct unpack_trees_options { |
480d3d6b | 58 | unsigned int merge, |
5a56da58 | 59 | update, |
04988c8d | 60 | preserve_ignored, |
b878579a | 61 | clone, |
5a56da58 | 62 | index_only, |
5a56da58 SB |
63 | trivial_merges_only, |
64 | verbose_update, | |
65 | aggressive, | |
66 | skip_unmerged, | |
67 | initial_checkout, | |
68 | diff_index_cached, | |
08aefc9e | 69 | skip_sparse_checkout, |
b165fac8 | 70 | quiet, |
b4194828 | 71 | exiting_early, |
68fcd48b VD |
72 | dry_run, |
73 | skip_cache_tree_update; | |
480d3d6b | 74 | enum unpack_trees_reset_type reset; |
16da134b | 75 | const char *prefix; |
4002ec3d | 76 | const char *super_prefix; |
40e37256 | 77 | struct pathspec *pathspec; |
16da134b JS |
78 | merge_fn_t fn; |
79 | ||
80 | int head_idx; | |
16da134b | 81 | |
f297424a | 82 | struct cache_entry *df_conflict_entry; /* output only */ |
d1f2d7e8 | 83 | void *unpack_data; |
34110cd4 LT |
84 | |
85 | struct index_state *dst_index; | |
32260ad5 | 86 | struct index_state *src_index; |
08aefc9e | 87 | |
13e7ed6a | 88 | struct checkout_metadata meta; |
576de3d9 EN |
89 | |
90 | struct unpack_trees_options_internal { | |
13e1fd6e | 91 | unsigned int nontrivial_merge, |
1ca13dd3 EN |
92 | show_all_errors, |
93 | debug_unpack; /* used by read-tree debugging */ | |
13e1fd6e | 94 | |
1ca13dd3 | 95 | int merge_size; /* used by read-tree debugging */ |
13e1fd6e EN |
96 | int cache_bottom; |
97 | const char *msgs[NB_UNPACK_TREES_WARNING_TYPES]; | |
98 | struct strvec msgs_to_free; | |
99 | ||
100 | /* | |
101 | * Store error messages in an array, each case | |
102 | * corresponding to a error message type | |
103 | */ | |
104 | struct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES]; | |
105 | ||
106 | struct index_state result; | |
107 | ||
576de3d9 EN |
108 | struct pattern_list *pl; |
109 | struct dir_struct *dir; | |
110 | } internal; | |
16da134b JS |
111 | }; |
112 | ||
340f4bc9 NTND |
113 | int unpack_trees(unsigned n, struct tree_desc *t, |
114 | struct unpack_trees_options *options); | |
16da134b | 115 | |
7af7a258 EN |
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 | |
121 | }; | |
122 | ||
1147c56f EN |
123 | enum update_sparsity_result update_sparsity(struct unpack_trees_options *options, |
124 | struct pattern_list *pl); | |
7af7a258 | 125 | |
64b1abe9 EN |
126 | int verify_uptodate(const struct cache_entry *ce, |
127 | struct unpack_trees_options *o); | |
128 | ||
5828e835 RS |
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); | |
d3c7bf73 DL |
137 | int stash_worktree_untracked_merge(const struct cache_entry * const *src, |
138 | struct unpack_trees_options *o); | |
076b0adc | 139 | |
16da134b | 140 | #endif |