unpack-trees.h 3.0 KB

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