sparse-checkout: avoid staging deletions of all files
[alt-git.git] / unpack-trees.h
blob0f7424aec614f9972df8e1b0521f60a4dd34bdf2
1 #ifndef UNPACK_TREES_H
2 #define UNPACK_TREES_H
4 #include "cache.h"
5 #include "argv-array.h"
6 #include "string-list.h"
7 #include "tree-walk.h"
9 #define MAX_UNPACK_TREES MAX_TRAVERSE_TREES
11 struct cache_entry;
12 struct unpack_trees_options;
13 struct pattern_list;
15 typedef int (*merge_fn_t)(const struct cache_entry * const *src,
16 struct unpack_trees_options *options);
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,
27 NB_UNPACK_TREES_ERROR_TYPES,
29 WARNING_SPARSE_NOT_UPTODATE_FILE,
30 WARNING_SPARSE_UNMERGED_FILE,
31 WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN,
33 NB_UNPACK_TREES_WARNING_TYPES,
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.
40 void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
41 const char *cmd);
44 * Frees resources allocated by setup_unpack_trees_porcelain().
46 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
48 struct unpack_trees_options {
49 unsigned int reset,
50 merge,
51 update,
52 clone,
53 index_only,
54 nontrivial_merge,
55 trivial_merges_only,
56 verbose_update,
57 aggressive,
58 skip_unmerged,
59 initial_checkout,
60 diff_index_cached,
61 debug_unpack,
62 skip_sparse_checkout,
63 quiet,
64 exiting_early,
65 show_all_errors,
66 dry_run;
67 const char *prefix;
68 int cache_bottom;
69 struct dir_struct *dir;
70 struct pathspec *pathspec;
71 merge_fn_t fn;
72 const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
73 struct argv_array msgs_to_free;
75 * Store error messages in an array, each case
76 * corresponding to a error message type
78 struct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES];
80 int head_idx;
81 int merge_size;
83 struct cache_entry *df_conflict_entry;
84 void *unpack_data;
86 struct index_state *dst_index;
87 struct index_state *src_index;
88 struct index_state result;
90 struct pattern_list *pl; /* for internal use */
93 int unpack_trees(unsigned n, struct tree_desc *t,
94 struct unpack_trees_options *options);
96 enum update_sparsity_result {
97 UPDATE_SPARSITY_SUCCESS = 0,
98 UPDATE_SPARSITY_WARNINGS = 1,
99 UPDATE_SPARSITY_INDEX_UPDATE_FAILURES = -1,
100 UPDATE_SPARSITY_WORKTREE_UPDATE_FAILURES = -2
103 enum update_sparsity_result update_sparsity(struct unpack_trees_options *options);
105 int verify_uptodate(const struct cache_entry *ce,
106 struct unpack_trees_options *o);
108 int threeway_merge(const struct cache_entry * const *stages,
109 struct unpack_trees_options *o);
110 int twoway_merge(const struct cache_entry * const *src,
111 struct unpack_trees_options *o);
112 int bind_merge(const struct cache_entry * const *src,
113 struct unpack_trees_options *o);
114 int oneway_merge(const struct cache_entry * const *src,
115 struct unpack_trees_options *o);
117 #endif