blob: 0135080a7b4e91713b66f68669e57a2f5e4edbdd [file] [log] [blame]
Johannes Schindelin16da1342006-07-30 20:25:18 +02001#ifndef UNPACK_TREES_H
2#define UNPACK_TREES_H
3
Elijah Newrenef3ca952018-08-15 10:54:05 -07004#include "cache.h"
Martin Ågren1c41d282018-05-21 16:54:28 +02005#include "argv-array.h"
Elijah Newrenef3ca952018-08-15 10:54:05 -07006#include "string-list.h"
7#include "tree-walk.h"
Clemens Buchacher79808722010-11-15 20:52:19 +01008
Junio C Hamanoca885a42008-03-13 22:07:18 -07009#define MAX_UNPACK_TREES 8
10
Elijah Newrenef3ca952018-08-15 10:54:05 -070011struct cache_entry;
Johannes Schindelin16da1342006-07-30 20:25:18 +020012struct unpack_trees_options;
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070013struct exclude_list;
Johannes Schindelin16da1342006-07-30 20:25:18 +020014
René Scharfe5828e832013-06-02 17:46:56 +020015typedef int (*merge_fn_t)(const struct cache_entry * const *src,
Linus Torvalds34110cd2008-03-06 18:12:28 -080016 struct unpack_trees_options *options);
Johannes Schindelin16da1342006-07-30 20:25:18 +020017
Matthieu Moy08353eb2010-08-11 10:38:04 +020018enum unpack_trees_error_types {
19 ERROR_WOULD_OVERWRITE = 0,
20 ERROR_NOT_UPTODATE_FILE,
21 ERROR_NOT_UPTODATE_DIR,
Matthieu Moy08402b02010-08-11 10:38:06 +020022 ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
23 ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
Matthieu Moy08353eb2010-08-11 10:38:04 +020024 ERROR_BIND_OVERLAP,
25 ERROR_SPARSE_NOT_UPTODATE_FILE,
Matthieu Moy08402b02010-08-11 10:38:06 +020026 ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN,
27 ERROR_WOULD_LOSE_ORPHANED_REMOVED,
Stefan Bellera7bc8452017-03-14 14:46:39 -070028 ERROR_WOULD_LOSE_SUBMODULE,
Matthieu Moy08353eb2010-08-11 10:38:04 +020029 NB_UNPACK_TREES_ERROR_TYPES
Junio C Hamano8ccba002008-05-17 12:03:49 -070030};
31
Matthieu Moydc1166e2010-09-02 13:57:33 +020032/*
33 * Sets the list of user-friendly error messages to be used by the
Matthieu Moy5e65ee32010-09-02 18:08:15 +020034 * command "cmd" (either merge or checkout), and show_all_errors to 1.
Matthieu Moydc1166e2010-09-02 13:57:33 +020035 */
Matthieu Moye2940302010-09-02 13:57:34 +020036void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
37 const char *cmd);
Matthieu Moydc1166e2010-09-02 13:57:33 +020038
Martin Ågren1c41d282018-05-21 16:54:28 +020039/*
40 * Frees resources allocated by setup_unpack_trees_porcelain().
41 */
42void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
43
Johannes Schindelin16da1342006-07-30 20:25:18 +020044struct unpack_trees_options {
Stephen Boyd5a56da52009-06-25 22:14:10 -070045 unsigned int reset,
46 merge,
47 update,
Duy Nguyenb8785792018-08-17 20:00:39 +020048 clone,
Stephen Boyd5a56da52009-06-25 22:14:10 -070049 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 Hamanoba655da2009-09-14 02:22:00 -070057 debug_unpack,
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070058 skip_sparse_checkout,
Matthieu Moye6c111b2010-08-11 10:38:07 +020059 gently,
Junio C Hamanob4194822011-05-31 10:06:44 -070060 exiting_early,
Jens Lehmann2c9078d2011-05-25 22:07:51 +020061 show_all_errors,
62 dry_run;
Johannes Schindelin16da1342006-07-30 20:25:18 +020063 const char *prefix;
Junio C Hamanoda165f42010-01-07 14:59:54 -080064 int cache_bottom;
Junio C Hamanof8a9d422006-12-04 16:00:46 -080065 struct dir_struct *dir;
Junio C Hamano40e37252011-08-29 12:31:06 -070066 struct pathspec *pathspec;
Johannes Schindelin16da1342006-07-30 20:25:18 +020067 merge_fn_t fn;
Matthieu Moy08353eb2010-08-11 10:38:04 +020068 const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
Martin Ågren1c41d282018-05-21 16:54:28 +020069 struct argv_array msgs_to_free;
Matthieu Moye6c111b2010-08-11 10:38:07 +020070 /*
71 * Store error messages in an array, each case
72 * corresponding to a error message type
73 */
Clemens Buchacher79808722010-11-15 20:52:19 +010074 struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
Johannes Schindelin16da1342006-07-30 20:25:18 +020075
76 int head_idx;
77 int merge_size;
78
79 struct cache_entry *df_conflict_entry;
Linus Torvaldsd1f2d7e2008-01-19 17:27:12 -080080 void *unpack_data;
Linus Torvalds34110cd2008-03-06 18:12:28 -080081
82 struct index_state *dst_index;
Linus Torvalds32260ad2008-03-22 09:35:59 -070083 struct index_state *src_index;
Linus Torvalds34110cd2008-03-06 18:12:28 -080084 struct index_state result;
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070085
86 struct exclude_list *el; /* for internal use */
Johannes Schindelin16da1342006-07-30 20:25:18 +020087};
88
Nguyễn Thái Ngọc Duy340f4bc2018-08-13 18:14:25 +020089int unpack_trees(unsigned n, struct tree_desc *t,
90 struct unpack_trees_options *options);
Johannes Schindelin16da1342006-07-30 20:25:18 +020091
Elijah Newren64b1abe2018-04-19 10:58:12 -070092int verify_uptodate(const struct cache_entry *ce,
93 struct unpack_trees_options *o);
94
René Scharfe5828e832013-06-02 17:46:56 +020095int threeway_merge(const struct cache_entry * const *stages,
96 struct unpack_trees_options *o);
97int twoway_merge(const struct cache_entry * const *src,
98 struct unpack_trees_options *o);
99int bind_merge(const struct cache_entry * const *src,
100 struct unpack_trees_options *o);
101int oneway_merge(const struct cache_entry * const *src,
102 struct unpack_trees_options *o);
Johannes Schindelin076b0ad2006-07-30 20:26:15 +0200103
Johannes Schindelin16da1342006-07-30 20:25:18 +0200104#endif