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