Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 1 | #ifndef UNPACK_TREES_H |
| 2 | #define UNPACK_TREES_H |
| 3 | |
Elijah Newren | ef3ca95 | 2018-08-15 10:54:05 -0700 | [diff] [blame] | 4 | #include "cache.h" |
Martin Ågren | 1c41d28 | 2018-05-21 16:54:28 +0200 | [diff] [blame] | 5 | #include "argv-array.h" |
Elijah Newren | ef3ca95 | 2018-08-15 10:54:05 -0700 | [diff] [blame] | 6 | #include "string-list.h" |
| 7 | #include "tree-walk.h" |
Clemens Buchacher | 7980872 | 2010-11-15 20:52:19 +0100 | [diff] [blame] | 8 | |
Junio C Hamano | ca885a4 | 2008-03-13 22:07:18 -0700 | [diff] [blame] | 9 | #define MAX_UNPACK_TREES 8 |
| 10 | |
Elijah Newren | ef3ca95 | 2018-08-15 10:54:05 -0700 | [diff] [blame] | 11 | struct cache_entry; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 12 | struct unpack_trees_options; |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 13 | struct exclude_list; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 14 | |
René Scharfe | 5828e83 | 2013-06-02 17:46:56 +0200 | [diff] [blame] | 15 | typedef int (*merge_fn_t)(const struct cache_entry * const *src, |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 16 | struct unpack_trees_options *options); |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 17 | |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 18 | enum unpack_trees_error_types { |
| 19 | ERROR_WOULD_OVERWRITE = 0, |
| 20 | ERROR_NOT_UPTODATE_FILE, |
| 21 | ERROR_NOT_UPTODATE_DIR, |
Matthieu Moy | 08402b0 | 2010-08-11 10:38:06 +0200 | [diff] [blame] | 22 | ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, |
| 23 | ERROR_WOULD_LOSE_UNTRACKED_REMOVED, |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 24 | ERROR_BIND_OVERLAP, |
| 25 | ERROR_SPARSE_NOT_UPTODATE_FILE, |
Matthieu Moy | 08402b0 | 2010-08-11 10:38:06 +0200 | [diff] [blame] | 26 | ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN, |
| 27 | ERROR_WOULD_LOSE_ORPHANED_REMOVED, |
Stefan Beller | a7bc845 | 2017-03-14 14:46:39 -0700 | [diff] [blame] | 28 | ERROR_WOULD_LOSE_SUBMODULE, |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 29 | NB_UNPACK_TREES_ERROR_TYPES |
Junio C Hamano | 8ccba00 | 2008-05-17 12:03:49 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 32 | /* |
| 33 | * 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] | 34 | * command "cmd" (either merge or checkout), and show_all_errors to 1. |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 35 | */ |
Matthieu Moy | e294030 | 2010-09-02 13:57:34 +0200 | [diff] [blame] | 36 | void setup_unpack_trees_porcelain(struct unpack_trees_options *opts, |
| 37 | const char *cmd); |
Matthieu Moy | dc1166e | 2010-09-02 13:57:33 +0200 | [diff] [blame] | 38 | |
Martin Ågren | 1c41d28 | 2018-05-21 16:54:28 +0200 | [diff] [blame] | 39 | /* |
| 40 | * Frees resources allocated by setup_unpack_trees_porcelain(). |
| 41 | */ |
| 42 | void clear_unpack_trees_porcelain(struct unpack_trees_options *opts); |
| 43 | |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 44 | struct unpack_trees_options { |
Stephen Boyd | 5a56da5 | 2009-06-25 22:14:10 -0700 | [diff] [blame] | 45 | unsigned int reset, |
| 46 | merge, |
| 47 | update, |
Duy Nguyen | b878579 | 2018-08-17 20:00:39 +0200 | [diff] [blame] | 48 | clone, |
Stephen Boyd | 5a56da5 | 2009-06-25 22:14:10 -0700 | [diff] [blame] | 49 | index_only, |
| 50 | nontrivial_merge, |
| 51 | trivial_merges_only, |
| 52 | verbose_update, |
| 53 | aggressive, |
| 54 | skip_unmerged, |
| 55 | initial_checkout, |
| 56 | diff_index_cached, |
Junio C Hamano | ba655da | 2009-09-14 02:22:00 -0700 | [diff] [blame] | 57 | debug_unpack, |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 58 | skip_sparse_checkout, |
Matthieu Moy | e6c111b | 2010-08-11 10:38:07 +0200 | [diff] [blame] | 59 | gently, |
Junio C Hamano | b419482 | 2011-05-31 10:06:44 -0700 | [diff] [blame] | 60 | exiting_early, |
Jens Lehmann | 2c9078d | 2011-05-25 22:07:51 +0200 | [diff] [blame] | 61 | show_all_errors, |
| 62 | dry_run; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 63 | const char *prefix; |
Junio C Hamano | da165f4 | 2010-01-07 14:59:54 -0800 | [diff] [blame] | 64 | int cache_bottom; |
Junio C Hamano | f8a9d42 | 2006-12-04 16:00:46 -0800 | [diff] [blame] | 65 | struct dir_struct *dir; |
Junio C Hamano | 40e3725 | 2011-08-29 12:31:06 -0700 | [diff] [blame] | 66 | struct pathspec *pathspec; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 67 | merge_fn_t fn; |
Matthieu Moy | 08353eb | 2010-08-11 10:38:04 +0200 | [diff] [blame] | 68 | const char *msgs[NB_UNPACK_TREES_ERROR_TYPES]; |
Martin Ågren | 1c41d28 | 2018-05-21 16:54:28 +0200 | [diff] [blame] | 69 | struct argv_array msgs_to_free; |
Matthieu Moy | e6c111b | 2010-08-11 10:38:07 +0200 | [diff] [blame] | 70 | /* |
| 71 | * Store error messages in an array, each case |
| 72 | * corresponding to a error message type |
| 73 | */ |
Clemens Buchacher | 7980872 | 2010-11-15 20:52:19 +0100 | [diff] [blame] | 74 | struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES]; |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 75 | |
| 76 | int head_idx; |
| 77 | int merge_size; |
| 78 | |
| 79 | struct cache_entry *df_conflict_entry; |
Linus Torvalds | d1f2d7e | 2008-01-19 17:27:12 -0800 | [diff] [blame] | 80 | void *unpack_data; |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 81 | |
| 82 | struct index_state *dst_index; |
Linus Torvalds | 32260ad | 2008-03-22 09:35:59 -0700 | [diff] [blame] | 83 | struct index_state *src_index; |
Linus Torvalds | 34110cd | 2008-03-06 18:12:28 -0800 | [diff] [blame] | 84 | struct index_state result; |
Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 20:47:08 +0700 | [diff] [blame] | 85 | |
| 86 | struct exclude_list *el; /* for internal use */ |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
Nguyễn Thái Ngọc Duy | 340f4bc | 2018-08-13 18:14:25 +0200 | [diff] [blame] | 89 | int unpack_trees(unsigned n, struct tree_desc *t, |
| 90 | struct unpack_trees_options *options); |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 91 | |
Elijah Newren | 64b1abe | 2018-04-19 10:58:12 -0700 | [diff] [blame] | 92 | int verify_uptodate(const struct cache_entry *ce, |
| 93 | struct unpack_trees_options *o); |
| 94 | |
René Scharfe | 5828e83 | 2013-06-02 17:46:56 +0200 | [diff] [blame] | 95 | int threeway_merge(const struct cache_entry * const *stages, |
| 96 | struct unpack_trees_options *o); |
| 97 | int twoway_merge(const struct cache_entry * const *src, |
| 98 | struct unpack_trees_options *o); |
| 99 | int bind_merge(const struct cache_entry * const *src, |
| 100 | struct unpack_trees_options *o); |
| 101 | int oneway_merge(const struct cache_entry * const *src, |
| 102 | struct unpack_trees_options *o); |
Johannes Schindelin | 076b0ad | 2006-07-30 20:26:15 +0200 | [diff] [blame] | 103 | |
Johannes Schindelin | 16da134 | 2006-07-30 20:25:18 +0200 | [diff] [blame] | 104 | #endif |