Commit 02105a27f01509ce4e641487cae040662ee477a2

Edward Thomson 2014-03-11T18:40:38

Change signature of `git_merge` to take merge and checkout opts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
diff --git a/include/git2/merge.h b/include/git2/merge.h
index e20025b..15bed2a 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -274,32 +274,6 @@ GIT_EXTERN(int) git_merge_status(
 	const git_merge_head **their_heads,
 	size_t their_heads_len);
 
-typedef struct {
-	unsigned int version;
-
-	/** Options for handling the merges of individual files. */
-	git_merge_tree_opts merge_tree_opts;
-
-	/** Options for writing the merge result to the working directory. */
-	git_checkout_options checkout_opts;
-} git_merge_opts;
-
-#define GIT_MERGE_OPTS_VERSION 1
-#define GIT_MERGE_OPTS_INIT {GIT_MERGE_OPTS_VERSION, GIT_MERGE_TREE_OPTS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
-
-/**
- * Initializes a `git_merge_opts` with default values. Equivalent to creating
- * an instance with GIT_MERGE_OPTS_INIT.
- *
- * @param opts the `git_merge_opts` instance to initialize.
- * @param version the version of the struct; you should pass
- *        `GIT_MERGE_OPTS_VERSION` here.
- * @return Zero on success; -1 on failure.
- */
-GIT_EXTERN(int) git_merge_init_opts(
-	git_merge_opts* opts,
-	int version);
-
 /**
  * Find a merge base between two commits
  *
@@ -522,7 +496,8 @@ GIT_EXTERN(int) git_merge_commits(
  * @param repo the repository to merge
  * @param merge_heads the heads to merge into
  * @param merge_heads_len the number of heads to merge
- * @param opts merge options
+ * @param checkout_opts merge options
+ * @param checkout_opts checkout options
  * @return 0 on success or error code
  */
 GIT_EXTERN(int) git_merge(
@@ -530,7 +505,8 @@ GIT_EXTERN(int) git_merge(
 	git_repository *repo,
 	const git_merge_head **their_heads,
 	size_t their_heads_len,
-	const git_merge_opts *opts);
+	const git_merge_tree_opts *merge_opts,
+	const git_checkout_options *checkout_opts);
 
 /**
  * Returns true if a merge is "up-to-date", meaning that the commit(s) 
diff --git a/src/merge.c b/src/merge.c
index b7f043a..12e4a3b 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2168,10 +2168,10 @@ const char *merge_their_label(const char *branchname)
 	return slash+1;
 }
 
-static int merge_normalize_opts(
+static int merge_normalize_checkout_opts(
 	git_repository *repo,
-	git_merge_opts *opts,
-	const git_merge_opts *given,
+	git_checkout_options *checkout_opts,
+	const git_checkout_options *given_checkout_opts,
 	const git_merge_head *ancestor_head,
 	const git_merge_head *our_head,
 	size_t their_heads_len,
@@ -2183,38 +2183,38 @@ static int merge_normalize_opts(
 
 	GIT_UNUSED(repo);
 
-	if (given != NULL)
-		memcpy(opts, given, sizeof(git_merge_opts));
+	if (given_checkout_opts != NULL)
+		memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options));
 	else {
-		git_merge_opts default_opts = GIT_MERGE_OPTS_INIT;
-		memcpy(opts, &default_opts, sizeof(git_merge_opts));
+		git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+		memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options));
 	}
 
-	if (!opts->checkout_opts.checkout_strategy)
-		opts->checkout_opts.checkout_strategy = default_checkout_strategy;
+	if (!checkout_opts->checkout_strategy)
+		checkout_opts->checkout_strategy = default_checkout_strategy;
 
 	/* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */
-	if (!opts->checkout_opts.ancestor_label) {
+	if (!checkout_opts->ancestor_label) {
 		if (ancestor_head && ancestor_head->commit)
-			opts->checkout_opts.ancestor_label = git_commit_summary(ancestor_head->commit);
+			checkout_opts->ancestor_label = git_commit_summary(ancestor_head->commit);
 		else
-			opts->checkout_opts.ancestor_label = "ancestor";
+			checkout_opts->ancestor_label = "ancestor";
 	}
 
-	if (!opts->checkout_opts.our_label) {
+	if (!checkout_opts->our_label) {
 		if (our_head && our_head->ref_name)
-			opts->checkout_opts.our_label = our_head->ref_name;
+			checkout_opts->our_label = our_head->ref_name;
 		else
-			opts->checkout_opts.our_label = "ours";
+			checkout_opts->our_label = "ours";
 	}
 
-	if (!opts->checkout_opts.their_label) {
+	if (!checkout_opts->their_label) {
 		if (their_heads_len == 1 && their_heads[0]->ref_name)
-			opts->checkout_opts.their_label = merge_their_label(their_heads[0]->ref_name);
+			checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name);
 		else if (their_heads_len == 1)
-			opts->checkout_opts.their_label = their_heads[0]->oid_str;
+			checkout_opts->their_label = their_heads[0]->oid_str;
 		else
-			opts->checkout_opts.their_label = "theirs";
+			checkout_opts->their_label = "theirs";
 	}
 
 	return error;
@@ -2552,11 +2552,12 @@ int git_merge(
 	git_repository *repo,
 	const git_merge_head **their_heads,
 	size_t their_heads_len,
-	const git_merge_opts *given_opts)
+	const git_merge_tree_opts *merge_opts,
+	const git_checkout_options *given_checkout_opts)
 {
 	git_merge_result *result;
-	git_merge_opts opts;
 	git_reference *our_ref = NULL;
+	git_checkout_options checkout_opts;
 	git_merge_head *ancestor_head = NULL, *our_head = NULL;
 	git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL;
 	git_index *index_new = NULL, *index_repo = NULL;
@@ -2567,8 +2568,6 @@ int git_merge(
 
 	*out = NULL;
 
-	GITERR_CHECK_VERSION(given_opts, GIT_MERGE_OPTS_VERSION, "git_merge_opts");
-
 	if (their_heads_len != 1) {
 		giterr_set(GITERR_MERGE, "Can only merge a single branch");
 		return -1;
@@ -2583,7 +2582,8 @@ int git_merge(
 	if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0)
 		goto on_error;
 
-	if ((error = merge_normalize_opts(repo, &opts, given_opts, ancestor_head, our_head, their_heads_len, their_heads)) < 0)
+	if ((error = merge_normalize_checkout_opts(repo, &checkout_opts, given_checkout_opts,
+		ancestor_head, our_head, their_heads_len, their_heads)) < 0)
 		goto on_error;
 
 	/* Write the merge files to the repository. */
@@ -2604,10 +2604,10 @@ int git_merge(
 
 	/* TODO: recursive, octopus, etc... */
 
-	if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], &opts.merge_tree_opts)) < 0 ||
+	if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 ||
 		(error = git_merge__indexes(repo, index_new)) < 0 ||
 		(error = git_repository_index(&index_repo, repo)) < 0 ||
-		(error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
+		(error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0)
 		goto on_error;
 
 	result->index = index_new;
@@ -2779,18 +2779,6 @@ void git_merge_head_free(git_merge_head *head)
 	git__free(head);
 }
 
-int git_merge_init_opts(git_merge_opts* opts, int version)
-{
-	if (version != GIT_MERGE_OPTS_VERSION) {
-		giterr_set(GITERR_INVALID, "Invalid version %d for git_merge_opts", version);
-		return -1;
-	} else {
-		git_merge_opts o = GIT_MERGE_OPTS_INIT;
-		memcpy(opts, &o, sizeof(o));
-		return 0;
-	}
-}
-
 int git_merge_tree_init_opts(git_merge_tree_opts* opts, int version)
 {
 	if (version != GIT_MERGE_TREE_OPTS_VERSION) {
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 14a30b2..e3c2b9e 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -79,7 +79,9 @@ int merge_commits_from_branches(
 	return 0;
 }
 
-int merge_branches(git_merge_result **result, git_repository *repo, const char *ours_branch, const char *theirs_branch, git_merge_opts *opts)
+int merge_branches(git_merge_result **result, git_repository *repo,
+	const char *ours_branch, const char *theirs_branch,
+	git_merge_tree_opts *merge_opts, git_checkout_options *checkout_opts)
 {
 	git_reference *head_ref, *theirs_ref;
 	git_merge_head *theirs_head;
@@ -93,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo, const char *
 	cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch));
 	cl_git_pass(git_merge_head_from_ref(&theirs_head, repo, theirs_ref));
 
-	cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, opts));
+	cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
 
 	git_reference_free(head_ref);
 	git_reference_free(theirs_ref);
diff --git a/tests/merge/merge_helpers.h b/tests/merge/merge_helpers.h
index 63d1cb7..e5dc34b 100644
--- a/tests/merge/merge_helpers.h
+++ b/tests/merge/merge_helpers.h
@@ -93,7 +93,8 @@ int merge_commits_from_branches(
 	git_merge_tree_opts *opts);
 
 int merge_branches(git_merge_result **result, git_repository *repo,
-	const char *ours_branch, const char *theirs_branch, git_merge_opts *opts);
+	const char *ours_branch, const char *theirs_branch,
+	git_merge_tree_opts *merge_opts, git_checkout_options *checkout_opts);
 
 int merge_test_diff_list(git_merge_diff_list *diff_list, const struct merge_index_entry expected[], size_t expected_len);
 
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index a77f9b2..61b83a6 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -90,15 +90,16 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che
 {
 	git_oid their_oids[1];
 	git_merge_head *their_heads[1];
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 	int error;
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], MERGE_BRANCH_OID));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
 
-	opts.merge_tree_opts.file_favor = merge_file_favor;
-	opts.checkout_opts.checkout_strategy = checkout_strategy;
-	error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &opts);
+	merge_opts.file_favor = merge_file_favor;
+	checkout_opts.checkout_strategy = checkout_strategy;
+	error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
 
 	git_merge_head_free(their_heads[0]);
 
diff --git a/tests/merge/workdir/renames.c b/tests/merge/workdir/renames.c
index 2774772..14308ef 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/merge/workdir/renames.c
@@ -35,7 +35,7 @@ void test_merge_workdir_renames__cleanup(void)
 void test_merge_workdir_renames__renames(void)
 {
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
 		{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
@@ -64,10 +64,10 @@ void test_merge_workdir_renames__renames(void)
 		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "7-both-renamed.txt~rename_conflict_theirs" },
 	};
 
-	opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
-	opts.merge_tree_opts.rename_threshold = 50;
+	merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+	merge_opts.rename_threshold = 50;
 
-	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
+	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
 	cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
 
 	git_merge_result_free(result);
@@ -77,7 +77,8 @@ void test_merge_workdir_renames__ours(void)
 {
 	git_index *index;
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
 		{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
@@ -102,11 +103,11 @@ void test_merge_workdir_renames__ours(void)
 		{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "7-both-renamed.txt" },
 	};
 
-	opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
-	opts.merge_tree_opts.rename_threshold = 50;
-	opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
+	merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+	merge_opts.rename_threshold = 50;
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
 
-	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
+	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts));
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_git_pass(git_index_write(index));
 	cl_assert(merge_test_workdir(repo, merge_index_entries, 20));
@@ -118,7 +119,7 @@ void test_merge_workdir_renames__ours(void)
 void test_merge_workdir_renames__similar(void)
 {
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
 
 	/*
 	 * Note: this differs slightly from the core git merge result - there, 4a is
@@ -152,10 +153,10 @@ void test_merge_workdir_renames__similar(void)
 		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "7-both-renamed.txt~rename_conflict_theirs" },
 	};
 
-	opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
-	opts.merge_tree_opts.rename_threshold = 50;
+	merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+	merge_opts.rename_threshold = 50;
 
-	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
+	cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
 	cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
 
 	git_merge_result_free(result);
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index d23e454..7085995 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_merge_head *our_head, *their_heads[1];
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 	git_merge_result *result;
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
@@ -980,7 +979,7 @@ void test_merge_workdir_setup__retained_after_success(void)
 
 	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
 
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, &opts));
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -1000,7 +999,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
 	git_reference *octo1_ref;
 	git_merge_head *our_head, *their_heads[1];
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
 	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
@@ -1012,7 +1010,7 @@ void test_merge_workdir_setup__removed_after_failure(void)
 		"Conflicting file!\n\nMerge will fail!\n");
 
 	cl_git_fail(git_merge(
-		&result, repo, (const git_merge_head **)&their_heads[0], 1, &opts));
+		&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
 
 	cl_assert(!git_path_exists("merge-resolve/" GIT_MERGE_HEAD_FILE));
 	cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 07c60c5..e60b2db 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -97,14 +97,15 @@ static git_merge_result *merge_simple_branch(int merge_file_favor, int checkout_
 	git_oid their_oids[1];
 	git_merge_head *their_heads[1];
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_SIMPLE_OID));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
 
-	opts.merge_tree_opts.file_favor = merge_file_favor;
-	opts.checkout_opts.checkout_strategy = checkout_strategy;
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
+	merge_opts.file_favor = merge_file_favor;
+	checkout_opts.checkout_strategy = checkout_strategy;
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
 
 	git_merge_head_free(their_heads[0]);
 
@@ -522,7 +523,7 @@ void test_merge_workdir_simple__directory_file(void)
 	git_oid their_oids[1], head_commit_id;
 	git_merge_head *their_heads[1];
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
 	git_commit *head_commit;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -556,8 +557,8 @@ void test_merge_workdir_simple__directory_file(void)
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
 
-	opts.merge_tree_opts.file_favor = 0;
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
+	merge_opts.file_favor = 0;
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 20));
 
@@ -572,7 +573,7 @@ void test_merge_workdir_simple__unrelated(void)
 	git_oid their_oids[1];
 	git_merge_head *their_heads[1];
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
 		{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
@@ -589,8 +590,8 @@ void test_merge_workdir_simple__unrelated(void)
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_PARENT));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
 
-	opts.merge_tree_opts.file_favor = 0;
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
+	merge_opts.file_favor = 0;
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 9));
 
@@ -603,7 +604,7 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
 	git_oid their_oids[1];
 	git_merge_head *their_heads[1];
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
+	git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
 		{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
@@ -622,8 +623,8 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_OID));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
 
-	opts.merge_tree_opts.file_favor = 0;
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
+	merge_opts.file_favor = 0;
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 11));
 
@@ -638,7 +639,6 @@ void test_merge_workdir_simple__binary(void)
 	git_merge_head *their_head;
 	git_merge_result *result;
 	const git_index_entry *binary_entry;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
 		{ 0100644, "1c51d885170f57a0c4e8c69ff6363d91a5b51f85", 1, "binary" },
@@ -654,7 +654,7 @@ void test_merge_workdir_simple__binary(void)
 
 	cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
 
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
 
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index 42451bd..296f30d 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -32,7 +32,6 @@ void test_merge_workdir_submodules__automerge(void)
 	git_commit *our_commit;
 	git_merge_head *their_head;
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 	git_index *index;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -51,7 +50,7 @@ void test_merge_workdir_submodules__automerge(void)
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
 	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
 
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
 
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_assert(merge_test_index(index, merge_index_entries, 6));
@@ -70,7 +69,6 @@ void test_merge_workdir_submodules__take_changed(void)
 	git_commit *our_commit;
 	git_merge_head *their_head;
 	git_merge_result *result;
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 	git_index *index;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -87,7 +85,7 @@ void test_merge_workdir_submodules__take_changed(void)
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
 	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
 
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
 
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_assert(merge_test_index(index, merge_index_entries, 4));
diff --git a/tests/merge/workdir/trivial.c b/tests/merge/workdir/trivial.c
index 8b0d328..ffbb56c 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/merge/workdir/trivial.c
@@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs)
 	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 	git_reference *our_ref, *their_ref;
 	git_merge_head *their_heads[1];
-	git_merge_opts opts = GIT_MERGE_OPTS_INIT;
 	git_merge_result *result;
 
 	checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
@@ -49,7 +48,7 @@ static int merge_trivial(const char *ours, const char *theirs)
 	cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
 	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, their_ref));
 
-	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
+	cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
 
 	git_buf_free(&branch_buf);
 	git_reference_free(our_ref);
diff --git a/tests/structinit/structinit.c b/tests/structinit/structinit.c
index 61fe8c7..fc44898 100644
--- a/tests/structinit/structinit.c
+++ b/tests/structinit/structinit.c
@@ -80,11 +80,6 @@ void test_structinit_structinit__compare(void)
 		git_merge_tree_opts, GIT_MERGE_TREE_OPTS_VERSION, \
 		GIT_MERGE_TREE_OPTS_INIT, git_merge_tree_init_opts);
 
-	/* merge */
-	CHECK_MACRO_FUNC_INIT_EQUAL( \
-		git_merge_opts, GIT_MERGE_OPTS_VERSION, \
-		GIT_MERGE_OPTS_INIT, git_merge_init_opts);
-
 	/* push */
 	CHECK_MACRO_FUNC_INIT_EQUAL( \
 		git_push_options, GIT_PUSH_OPTIONS_VERSION, \