Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 1 | #ifndef UNPACK_TREES_H |
| 2 | #define UNPACK_TREES_H |
| 3 | |
Clemens Buchacher | 7980872 | 2010-11-15 20:52:19 +0100 | [diff] [blame] | 4 | #include "string-list.h" |
| 5 | |
Junio C Hamano | ca885a4 | 2008-03-13 22:07:18 -0700 | [diff] [blame] | 6 | #define MAX_UNPACK_TREES 8 |
| 7 | |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 8 | struct unpack_trees_options; |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 9 | struct exclude_list; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 10 | |
| 11 | typedef int (*merge_fn_t)(struct cache_entry **src, |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 12 | struct unpack_trees_options *options); |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 13 | |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 14 | enum unpack_trees_error_types { |
| 15 | ERROR_WOULD_OVERWRITE = 0, |
| 16 | ERROR_NOT_UPTODATE_FILE, |
| 17 | ERROR_NOT_UPTODATE_DIR, |
Matthieu Moy | 08402b0 | 2010-08-11 10:38:06 +0200 | [diff] [blame] | 18 | ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, |
| 19 | ERROR_WOULD_LOSE_UNTRACKED_REMOVED, |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 20 | ERROR_BIND_OVERLAP, |
| 21 | ERROR_SPARSE_NOT_UPTODATE_FILE, |
Matthieu Moy | 08402b0 | 2010-08-11 10:38:06 +0200 | [diff] [blame] | 22 | ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN, |
| 23 | ERROR_WOULD_LOSE_ORPHANED_REMOVED, |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 24 | NB_UNPACK_TREES_ERROR_TYPES |
Junio C Hamano | 8ccba00 | 2008-05-17 12:03:49 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 27 | /* |
| 28 | * Sets the list of user-friendly error messages to be used by the |
Matthieu Moy | 5e65ee3 | 2010-09-02 18:08:15 +0200 | [diff] [blame] | 29 | * command "cmd" (either merge or checkout), and show_all_errors to 1. |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 30 | */ |
Matthieu Moy | e294030 | 2010-09-02 13:57:34 +0200 | [diff] [blame] | 31 | void setup_unpack_trees_porcelain(struct unpack_trees_options *opts, |
| 32 | const char *cmd); |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 33 | |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 34 | struct unpack_trees_options { |
Stephen Boyd | 5a56da5 | 2009-06-25 22:14:10 -0700 | [diff] [blame] | 35 | 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 Hamano | ba655da | 2009-09-14 02:22:00 -0700 | [diff] [blame] | 46 | debug_unpack, |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 47 | skip_sparse_checkout, |
Matthieu Moy | e6c111b | 2010-08-11 10:38:07 +0200 | [diff] [blame] | 48 | gently, |
Junio C Hamano | b419482 | 2011-05-31 10:06:44 -0700 | [diff] [blame] | 49 | exiting_early, |
Jens Lehmann | 2c9078d | 2011-05-25 22:07:51 +0200 | [diff] [blame] | 50 | show_all_errors, |
| 51 | dry_run; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 52 | const char *prefix; |
Junio C Hamano | da165f4 | 2010-01-07 14:59:54 -0800 | [diff] [blame] | 53 | int cache_bottom; |
Junio C Hamano | f8a9d42 | 2006-12-04 16:00:46 -0800 | [diff] [blame] | 54 | struct dir_struct *dir; |
Junio C Hamano | 589570d | 2012-06-05 22:21:42 -0700 | [diff] [blame] | 55 | struct path_exclude_check *path_exclude_check; |
Junio C Hamano | 40e3725 | 2011-08-29 12:31:06 -0700 | [diff] [blame] | 56 | struct pathspec *pathspec; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 57 | merge_fn_t fn; |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 58 | const char *msgs[NB_UNPACK_TREES_ERROR_TYPES]; |
Matthieu Moy | e6c111b | 2010-08-11 10:38:07 +0200 | [diff] [blame] | 59 | /* |
| 60 | * Store error messages in an array, each case |
| 61 | * corresponding to a error message type |
| 62 | */ |
Clemens Buchacher | 7980872 | 2010-11-15 20:52:19 +0100 | [diff] [blame] | 63 | struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES]; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 64 | |
| 65 | int head_idx; |
| 66 | int merge_size; |
| 67 | |
| 68 | struct cache_entry *df_conflict_entry; |
Linus Torvalds | d1f2d7e | 2008-01-19 17:27:12 -0800 | [diff] [blame] | 69 | void *unpack_data; |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 70 | |
| 71 | struct index_state *dst_index; |
Linus Torvalds | 32260ad | 2008-03-22 09:35:59 -0700 | [diff] [blame] | 72 | struct index_state *src_index; |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 73 | struct index_state result; |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 74 | |
| 75 | struct exclude_list *el; /* for internal use */ |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
Linus Torvalds | 933bf40 | 2007-08-09 22:21:29 -0700 | [diff] [blame] | 78 | extern int unpack_trees(unsigned n, struct tree_desc *t, |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 79 | struct unpack_trees_options *options); |
| 80 | |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 81 | int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o); |
| 82 | int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o); |
| 83 | int bind_merge(struct cache_entry **src, struct unpack_trees_options *o); |
| 84 | int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o); |
Johannes Schindelin | 076b0ad | 2006-07-30 20:26:15 +0200 | [diff] [blame] | 85 | |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 86 | #endif |