unpack-trees.h 2.62 KB
Newer Older
1 2 3
#ifndef UNPACK_TREES_H
#define UNPACK_TREES_H

4
#include "cache.h"
5
#include "argv-array.h"
6 7
#include "string-list.h"
#include "tree-walk.h"
8

9 10
#define MAX_UNPACK_TREES 8

11
struct cache_entry;
12
struct unpack_trees_options;
13
struct exclude_list;
14

15
typedef int (*merge_fn_t)(const struct cache_entry * const *src,
16
		struct unpack_trees_options *options);
17

18 19 20 21
enum unpack_trees_error_types {
	ERROR_WOULD_OVERWRITE = 0,
	ERROR_NOT_UPTODATE_FILE,
	ERROR_NOT_UPTODATE_DIR,
22 23
	ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
	ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
24 25
	ERROR_BIND_OVERLAP,
	ERROR_SPARSE_NOT_UPTODATE_FILE,
26 27
	ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN,
	ERROR_WOULD_LOSE_ORPHANED_REMOVED,
28
	ERROR_WOULD_LOSE_SUBMODULE,
29
	NB_UNPACK_TREES_ERROR_TYPES
30 31
};

32 33
/*
 * Sets the list of user-friendly error messages to be used by the
34
 * command "cmd" (either merge or checkout), and show_all_errors to 1.
35
 */
36 37
void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
				  const char *cmd);
38

39 40 41 42 43
/*
 * Frees resources allocated by setup_unpack_trees_porcelain().
 */
void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);

44
struct unpack_trees_options {
45 46 47
	unsigned int reset,
		     merge,
		     update,
48
		     clone,
49 50 51 52 53 54 55 56
		     index_only,
		     nontrivial_merge,
		     trivial_merges_only,
		     verbose_update,
		     aggressive,
		     skip_unmerged,
		     initial_checkout,
		     diff_index_cached,
57
		     debug_unpack,
58
		     skip_sparse_checkout,
59
		     quiet,
60
		     exiting_early,
61 62
		     show_all_errors,
		     dry_run;
63
	const char *prefix;
64
	int cache_bottom;
65
	struct dir_struct *dir;
66
	struct pathspec *pathspec;
67
	merge_fn_t fn;
68
	const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
69
	struct argv_array msgs_to_free;
70 71 72 73
	/*
	 * Store error messages in an array, each case
	 * corresponding to a error message type
	 */
74
	struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
75 76 77 78 79

	int head_idx;
	int merge_size;

	struct cache_entry *df_conflict_entry;
80
	void *unpack_data;
81 82

	struct index_state *dst_index;
83
	struct index_state *src_index;
84
	struct index_state result;
85 86

	struct exclude_list *el; /* for internal use */
87 88
};

89 90
int unpack_trees(unsigned n, struct tree_desc *t,
		 struct unpack_trees_options *options);
91

92 93 94
int verify_uptodate(const struct cache_entry *ce,
		    struct unpack_trees_options *o);

95 96 97 98 99 100 101 102
int threeway_merge(const struct cache_entry * const *stages,
		   struct unpack_trees_options *o);
int twoway_merge(const struct cache_entry * const *src,
		 struct unpack_trees_options *o);
int bind_merge(const struct cache_entry * const *src,
	       struct unpack_trees_options *o);
int oneway_merge(const struct cache_entry * const *src,
		 struct unpack_trees_options *o);
103

104
#endif