blob: ec74a9f19a47c39de61def9709da6d4d6f1dcbdb [file] [log] [blame]
Johannes Schindelin16da1342006-07-30 20:25:18 +02001#ifndef UNPACK_TREES_H
2#define UNPACK_TREES_H
3
Clemens Buchacher79808722010-11-15 20:52:19 +01004#include "string-list.h"
5
Junio C Hamanoca885a42008-03-13 22:07:18 -07006#define MAX_UNPACK_TREES 8
7
Johannes Schindelin16da1342006-07-30 20:25:18 +02008struct unpack_trees_options;
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +07009struct exclude_list;
Johannes Schindelin16da1342006-07-30 20:25:18 +020010
11typedef int (*merge_fn_t)(struct cache_entry **src,
Linus Torvalds34110cd2008-03-06 18:12:28 -080012 struct unpack_trees_options *options);
Johannes Schindelin16da1342006-07-30 20:25:18 +020013
Matthieu Moy08353eb2010-08-11 10:38:04 +020014enum unpack_trees_error_types {
15 ERROR_WOULD_OVERWRITE = 0,
16 ERROR_NOT_UPTODATE_FILE,
17 ERROR_NOT_UPTODATE_DIR,
Matthieu Moy08402b02010-08-11 10:38:06 +020018 ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
19 ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
Matthieu Moy08353eb2010-08-11 10:38:04 +020020 ERROR_BIND_OVERLAP,
21 ERROR_SPARSE_NOT_UPTODATE_FILE,
Matthieu Moy08402b02010-08-11 10:38:06 +020022 ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN,
23 ERROR_WOULD_LOSE_ORPHANED_REMOVED,
Matthieu Moy08353eb2010-08-11 10:38:04 +020024 NB_UNPACK_TREES_ERROR_TYPES
Junio C Hamano8ccba002008-05-17 12:03:49 -070025};
26
Matthieu Moydc1166e2010-09-02 13:57:33 +020027/*
28 * Sets the list of user-friendly error messages to be used by the
Matthieu Moy5e65ee32010-09-02 18:08:15 +020029 * command "cmd" (either merge or checkout), and show_all_errors to 1.
Matthieu Moydc1166e2010-09-02 13:57:33 +020030 */
Matthieu Moye2940302010-09-02 13:57:34 +020031void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
32 const char *cmd);
Matthieu Moydc1166e2010-09-02 13:57:33 +020033
Johannes Schindelin16da1342006-07-30 20:25:18 +020034struct unpack_trees_options {
Stephen Boyd5a56da52009-06-25 22:14:10 -070035 unsigned int reset,
36 merge,
37 update,
38 index_only,
39 nontrivial_merge,
40 trivial_merges_only,
41 verbose_update,
42 aggressive,
43 skip_unmerged,
44 initial_checkout,
45 diff_index_cached,
Junio C Hamanoba655da2009-09-14 02:22:00 -070046 debug_unpack,
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070047 skip_sparse_checkout,
Matthieu Moye6c111b2010-08-11 10:38:07 +020048 gently,
Junio C Hamanob4194822011-05-31 10:06:44 -070049 exiting_early,
Jens Lehmann2c9078d2011-05-25 22:07:51 +020050 show_all_errors,
51 dry_run;
Johannes Schindelin16da1342006-07-30 20:25:18 +020052 const char *prefix;
Junio C Hamanoda165f42010-01-07 14:59:54 -080053 int cache_bottom;
Junio C Hamanof8a9d422006-12-04 16:00:46 -080054 struct dir_struct *dir;
Junio C Hamano589570d2012-06-05 22:21:42 -070055 struct path_exclude_check *path_exclude_check;
Junio C Hamano40e37252011-08-29 12:31:06 -070056 struct pathspec *pathspec;
Johannes Schindelin16da1342006-07-30 20:25:18 +020057 merge_fn_t fn;
Matthieu Moy08353eb2010-08-11 10:38:04 +020058 const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
Matthieu Moye6c111b2010-08-11 10:38:07 +020059 /*
60 * Store error messages in an array, each case
61 * corresponding to a error message type
62 */
Clemens Buchacher79808722010-11-15 20:52:19 +010063 struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
Johannes Schindelin16da1342006-07-30 20:25:18 +020064
65 int head_idx;
66 int merge_size;
67
68 struct cache_entry *df_conflict_entry;
Linus Torvaldsd1f2d7e2008-01-19 17:27:12 -080069 void *unpack_data;
Linus Torvalds34110cd2008-03-06 18:12:28 -080070
71 struct index_state *dst_index;
Linus Torvalds32260ad2008-03-22 09:35:59 -070072 struct index_state *src_index;
Linus Torvalds34110cd2008-03-06 18:12:28 -080073 struct index_state result;
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070074
75 struct exclude_list *el; /* for internal use */
Johannes Schindelin16da1342006-07-30 20:25:18 +020076};
77
Linus Torvalds933bf402007-08-09 22:21:29 -070078extern int unpack_trees(unsigned n, struct tree_desc *t,
Johannes Schindelin16da1342006-07-30 20:25:18 +020079 struct unpack_trees_options *options);
80
Linus Torvalds34110cd2008-03-06 18:12:28 -080081int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o);
82int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o);
83int bind_merge(struct cache_entry **src, struct unpack_trees_options *o);
84int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o);
Johannes Schindelin076b0ad2006-07-30 20:26:15 +020085
Johannes Schindelin16da1342006-07-30 20:25:18 +020086#endif