| 5016 | } |
| 5017 | |
| 5018 | static void merge_start(struct merge_options *opt, struct merge_result *result) |
| 5019 | { |
| 5020 | struct rename_info *renames; |
| 5021 | int i; |
| 5022 | struct mem_pool *pool = NULL; |
| 5023 | |
| 5024 | /* Sanity checks on opt */ |
| 5025 | trace2_region_enter("merge", "sanity checks", opt->repo); |
| 5026 | assert(opt->repo); |
| 5027 | |
| 5028 | assert(opt->branch1 && opt->branch2); |
| 5029 | |
| 5030 | assert(opt->detect_directory_renames >= MERGE_DIRECTORY_RENAMES_NONE && |
| 5031 | opt->detect_directory_renames <= MERGE_DIRECTORY_RENAMES_TRUE); |
| 5032 | assert(opt->rename_limit >= -1); |
| 5033 | assert(opt->rename_score >= 0 && opt->rename_score <= MAX_SCORE); |
| 5034 | assert(opt->show_rename_progress >= 0 && opt->show_rename_progress <= 1); |
| 5035 | |
| 5036 | assert(opt->xdl_opts >= 0); |
| 5037 | assert(opt->recursive_variant >= MERGE_VARIANT_NORMAL && |
| 5038 | opt->recursive_variant <= MERGE_VARIANT_THEIRS); |
| 5039 | |
| 5040 | if (opt->msg_header_prefix) |
| 5041 | assert(opt->record_conflict_msgs_as_headers); |
| 5042 | |
| 5043 | /* |
| 5044 | * detect_renames, verbosity, buffer_output, and obuf are ignored |
| 5045 | * fields that were used by "recursive" rather than "ort" -- but |
| 5046 | * sanity check them anyway. |
| 5047 | */ |
| 5048 | assert(opt->detect_renames >= -1 && |
| 5049 | opt->detect_renames <= DIFF_DETECT_COPY); |
| 5050 | assert(opt->verbosity >= 0 && opt->verbosity <= 5); |
| 5051 | assert(opt->buffer_output <= 2); |
| 5052 | assert(opt->obuf.len == 0); |
| 5053 | |
| 5054 | assert(opt->priv == NULL); |
| 5055 | if (result->_properly_initialized != 0 && |
| 5056 | result->_properly_initialized != RESULT_INITIALIZED) |
| 5057 | BUG("struct merge_result passed to merge_incore_*recursive() must be zeroed or filled with values from a previous run"); |
| 5058 | assert(!!result->priv == !!result->_properly_initialized); |
| 5059 | if (result->priv) { |
| 5060 | opt->priv = result->priv; |
| 5061 | result->priv = NULL; |
| 5062 | /* |
| 5063 | * opt->priv non-NULL means we had results from a previous |
| 5064 | * run; do a few sanity checks that user didn't mess with |
| 5065 | * it in an obvious fashion. |
| 5066 | */ |
| 5067 | assert(opt->priv->call_depth == 0); |
| 5068 | assert(!opt->priv->toplevel_dir || |
| 5069 | 0 == strlen(opt->priv->toplevel_dir)); |
| 5070 | } |
| 5071 | trace2_region_leave("merge", "sanity checks", opt->repo); |
| 5072 | |
| 5073 | /* Handle attr direction stuff for renormalization */ |
| 5074 | if (opt->renormalize) |
| 5075 | git_attr_set_direction(GIT_ATTR_CHECKOUT); |
no test coverage detected