blob: cd11a08365ab3e27b1321b3df87bcab6b9278f90 [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,
49 show_all_errors;
Johannes Schindelin16da1342006-07-30 20:25:18 +020050 const char *prefix;
Junio C Hamanoda165f42010-01-07 14:59:54 -080051 int cache_bottom;
Junio C Hamanof8a9d422006-12-04 16:00:46 -080052 struct dir_struct *dir;
Johannes Schindelin16da1342006-07-30 20:25:18 +020053 merge_fn_t fn;
Matthieu Moy08353eb2010-08-11 10:38:04 +020054 const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
Matthieu Moye6c111b2010-08-11 10:38:07 +020055 /*
56 * Store error messages in an array, each case
57 * corresponding to a error message type
58 */
Clemens Buchacher79808722010-11-15 20:52:19 +010059 struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
Johannes Schindelin16da1342006-07-30 20:25:18 +020060
61 int head_idx;
62 int merge_size;
63
64 struct cache_entry *df_conflict_entry;
Linus Torvaldsd1f2d7e2008-01-19 17:27:12 -080065 void *unpack_data;
Linus Torvalds34110cd2008-03-06 18:12:28 -080066
67 struct index_state *dst_index;
Linus Torvalds32260ad2008-03-22 09:35:59 -070068 struct index_state *src_index;
Linus Torvalds34110cd2008-03-06 18:12:28 -080069 struct index_state result;
Nguyễn Thái Ngọc Duy08aefc92009-08-20 20:47:08 +070070
71 struct exclude_list *el; /* for internal use */
Johannes Schindelin16da1342006-07-30 20:25:18 +020072};
73
Linus Torvalds933bf402007-08-09 22:21:29 -070074extern int unpack_trees(unsigned n, struct tree_desc *t,
Johannes Schindelin16da1342006-07-30 20:25:18 +020075 struct unpack_trees_options *options);
76
Linus Torvalds34110cd2008-03-06 18:12:28 -080077int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o);
78int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o);
79int bind_merge(struct cache_entry **src, struct unpack_trees_options *o);
80int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o);
Johannes Schindelin076b0ad2006-07-30 20:26:15 +020081
Johannes Schindelin16da1342006-07-30 20:25:18 +020082#endif