|
17 | 17 | #include "cache.h"
|
18 | 18 | #include "merge-ort.h"
|
19 | 19 |
|
| 20 | +#include "diff.h" |
| 21 | +#include "diffcore.h" |
20 | 22 | #include "strmap.h"
|
21 | 23 | #include "tree.h"
|
22 | 24 |
|
@@ -215,7 +217,48 @@ void merge_finalize(struct merge_options *opt,
|
215 | 217 |
|
216 | 218 | static void merge_start(struct merge_options *opt, struct merge_result *result)
|
217 | 219 | {
|
218 |
| - die("Not yet implemented."); |
| 220 | + /* Sanity checks on opt */ |
| 221 | + assert(opt->repo); |
| 222 | + |
| 223 | + assert(opt->branch1 && opt->branch2); |
| 224 | + |
| 225 | + assert(opt->detect_directory_renames >= MERGE_DIRECTORY_RENAMES_NONE && |
| 226 | + opt->detect_directory_renames <= MERGE_DIRECTORY_RENAMES_TRUE); |
| 227 | + assert(opt->rename_limit >= -1); |
| 228 | + assert(opt->rename_score >= 0 && opt->rename_score <= MAX_SCORE); |
| 229 | + assert(opt->show_rename_progress >= 0 && opt->show_rename_progress <= 1); |
| 230 | + |
| 231 | + assert(opt->xdl_opts >= 0); |
| 232 | + assert(opt->recursive_variant >= MERGE_VARIANT_NORMAL && |
| 233 | + opt->recursive_variant <= MERGE_VARIANT_THEIRS); |
| 234 | + |
| 235 | + /* |
| 236 | + * detect_renames, verbosity, buffer_output, and obuf are ignored |
| 237 | + * fields that were used by "recursive" rather than "ort" -- but |
| 238 | + * sanity check them anyway. |
| 239 | + */ |
| 240 | + assert(opt->detect_renames >= -1 && |
| 241 | + opt->detect_renames <= DIFF_DETECT_COPY); |
| 242 | + assert(opt->verbosity >= 0 && opt->verbosity <= 5); |
| 243 | + assert(opt->buffer_output <= 2); |
| 244 | + assert(opt->obuf.len == 0); |
| 245 | + |
| 246 | + assert(opt->priv == NULL); |
| 247 | + |
| 248 | + /* Initialization of opt->priv, our internal merge data */ |
| 249 | + opt->priv = xcalloc(1, sizeof(*opt->priv)); |
| 250 | + |
| 251 | + /* |
| 252 | + * Although we initialize opt->priv->paths with strdup_strings=0, |
| 253 | + * that's just to avoid making yet another copy of an allocated |
| 254 | + * string. Putting the entry into paths means we are taking |
| 255 | + * ownership, so we will later free it. |
| 256 | + * |
| 257 | + * In contrast, conflicted just has a subset of keys from paths, so |
| 258 | + * we don't want to free those (it'd be a duplicate free). |
| 259 | + */ |
| 260 | + strmap_init_with_options(&opt->priv->paths, NULL, 0); |
| 261 | + strmap_init_with_options(&opt->priv->conflicted, NULL, 0); |
219 | 262 | }
|
220 | 263 |
|
221 | 264 | /*
|
|
0 commit comments