unpack-trees.hon commit Merge branch 'jt/non-blob-lazy-fetch' into maint (0811737)
   1#ifndef UNPACK_TREES_H
   2#define UNPACK_TREES_H
   3
   4#include "cache.h"
   5#include "argv-array.h"
   6#include "string-list.h"
   7#include "tree-walk.h"
   8
   9#define MAX_UNPACK_TREES 8
  10
  11struct cache_entry;
  12struct unpack_trees_options;
  13struct exclude_list;
  14
  15typedef int (*merge_fn_t)(const struct cache_entry * const *src,
  16                struct unpack_trees_options *options);
  17
  18enum unpack_trees_error_types {
  19        ERROR_WOULD_OVERWRITE = 0,
  20        ERROR_NOT_UPTODATE_FILE,
  21        ERROR_NOT_UPTODATE_DIR,
  22        ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN,
  23        ERROR_WOULD_LOSE_UNTRACKED_REMOVED,
  24        ERROR_BIND_OVERLAP,
  25        ERROR_SPARSE_NOT_UPTODATE_FILE,
  26        ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN,
  27        ERROR_WOULD_LOSE_ORPHANED_REMOVED,
  28        ERROR_WOULD_LOSE_SUBMODULE,
  29        NB_UNPACK_TREES_ERROR_TYPES
  30};
  31
  32/*
  33 * Sets the list of user-friendly error messages to be used by the
  34 * command "cmd" (either merge or checkout), and show_all_errors to 1.
  35 */
  36void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
  37                                  const char *cmd);
  38
  39/*
  40 * Frees resources allocated by setup_unpack_trees_porcelain().
  41 */
  42void clear_unpack_trees_porcelain(struct unpack_trees_options *opts);
  43
  44struct unpack_trees_options {
  45        unsigned int reset,
  46                     merge,
  47                     update,
  48                     index_only,
  49                     nontrivial_merge,
  50                     trivial_merges_only,
  51                     verbose_update,
  52                     aggressive,
  53                     skip_unmerged,
  54                     initial_checkout,
  55                     diff_index_cached,
  56                     debug_unpack,
  57                     skip_sparse_checkout,
  58                     gently,
  59                     exiting_early,
  60                     show_all_errors,
  61                     dry_run;
  62        const char *prefix;
  63        int cache_bottom;
  64        struct dir_struct *dir;
  65        struct pathspec *pathspec;
  66        merge_fn_t fn;
  67        const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
  68        struct argv_array msgs_to_free;
  69        /*
  70         * Store error messages in an array, each case
  71         * corresponding to a error message type
  72         */
  73        struct string_list unpack_rejects[NB_UNPACK_TREES_ERROR_TYPES];
  74
  75        int head_idx;
  76        int merge_size;
  77
  78        struct cache_entry *df_conflict_entry;
  79        void *unpack_data;
  80
  81        struct index_state *dst_index;
  82        struct index_state *src_index;
  83        struct index_state result;
  84
  85        struct exclude_list *el; /* for internal use */
  86};
  87
  88int unpack_trees(unsigned n, struct tree_desc *t,
  89                 struct unpack_trees_options *options);
  90
  91int verify_uptodate(const struct cache_entry *ce,
  92                    struct unpack_trees_options *o);
  93
  94int threeway_merge(const struct cache_entry * const *stages,
  95                   struct unpack_trees_options *o);
  96int twoway_merge(const struct cache_entry * const *src,
  97                 struct unpack_trees_options *o);
  98int bind_merge(const struct cache_entry * const *src,
  99               struct unpack_trees_options *o);
 100int oneway_merge(const struct cache_entry * const *src,
 101                 struct unpack_trees_options *o);
 102
 103#endif