@@ -25,7 +25,7 @@ void test_merge_trees_trivial__cleanup(void)
25
25
}
26
26
27
27
28
- static int merge_trivial (git_index * * index , const char * ours , const char * theirs )
28
+ static int merge_trivial (git_index * * index , const char * ours , const char * theirs , bool ancestor_use_parent )
29
29
{
30
30
git_commit * our_commit , * their_commit , * ancestor_commit ;
31
31
git_tree * our_tree , * their_tree , * ancestor_tree ;
@@ -42,8 +42,12 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs
42
42
cl_git_pass (git_reference_name_to_id (& their_oid , repo , branch_buf .ptr ));
43
43
cl_git_pass (git_commit_lookup (& their_commit , repo , & their_oid ));
44
44
45
- cl_git_pass (git_merge_base (& ancestor_oid , repo , git_commit_id (our_commit ), git_commit_id (their_commit )));
46
- cl_git_pass (git_commit_lookup (& ancestor_commit , repo , & ancestor_oid ));
45
+ if (!ancestor_use_parent ) {
46
+ cl_git_pass (git_merge_base (& ancestor_oid , repo , git_commit_id (our_commit ), git_commit_id (their_commit )));
47
+ cl_git_pass (git_commit_lookup (& ancestor_commit , repo , & ancestor_oid ));
48
+ } else {
49
+ cl_git_pass (git_commit_parent (& ancestor_commit , their_commit , 0 ));
50
+ }
47
51
48
52
cl_git_pass (git_commit_tree (& ancestor_tree , ancestor_commit ));
49
53
cl_git_pass (git_commit_tree (& our_tree , our_commit ));
@@ -84,7 +88,7 @@ void test_merge_trees_trivial__2alt(void)
84
88
git_index * result ;
85
89
const git_index_entry * entry ;
86
90
87
- cl_git_pass (merge_trivial (& result , "trivial-2alt" , "trivial-2alt-branch" ));
91
+ cl_git_pass (merge_trivial (& result , "trivial-2alt" , "trivial-2alt-branch" , false ));
88
92
89
93
cl_assert (entry = git_index_get_bypath (result , "new-in-branch.txt" , 0 ));
90
94
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -99,7 +103,7 @@ void test_merge_trees_trivial__3alt(void)
99
103
git_index * result ;
100
104
const git_index_entry * entry ;
101
105
102
- cl_git_pass (merge_trivial (& result , "trivial-3alt" , "trivial-3alt-branch" ));
106
+ cl_git_pass (merge_trivial (& result , "trivial-3alt" , "trivial-3alt-branch" , false ));
103
107
104
108
cl_assert (entry = git_index_get_bypath (result , "new-in-3alt.txt" , 0 ));
105
109
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -114,7 +118,7 @@ void test_merge_trees_trivial__4(void)
114
118
git_index * result ;
115
119
const git_index_entry * entry ;
116
120
117
- cl_git_pass (merge_trivial (& result , "trivial-4" , "trivial-4-branch" ));
121
+ cl_git_pass (merge_trivial (& result , "trivial-4" , "trivial-4-branch" , false ));
118
122
119
123
cl_assert ((entry = git_index_get_bypath (result , "new-and-different.txt" , 0 )) == NULL );
120
124
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -132,7 +136,7 @@ void test_merge_trees_trivial__5alt_1(void)
132
136
git_index * result ;
133
137
const git_index_entry * entry ;
134
138
10000
135
- cl_git_pass (merge_trivial (& result , "trivial-5alt-1" , "trivial-5alt-1-branch" ));
139
+ cl_git_pass (merge_trivial (& result , "trivial-5alt-1" , "trivial-5alt-1-branch" , false ));
136
140
137
141
cl_assert (entry = git_index_get_bypath (result , "new-and-same.txt" , 0 ));
138
142
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -147,7 +151,7 @@ void test_merge_trees_trivial__5alt_2(void)
147
151
git_index * result ;
148
152
const git_index_entry * entry ;
149
153
150
- cl_git_pass (merge_trivial (& result , "trivial-5alt-2" , "trivial-5alt-2-branch" ));
154
+ cl_git_pass (merge_trivial (& result , "trivial-5alt-2" , "trivial-5alt-2-branch" , false ));
151
155
152
156
cl_assert (entry = git_index_get_bypath (result , "modified-to-same.txt" , 0 ));
153
157
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -163,7 +167,7 @@ void test_merge_trees_trivial__6(void)
163
167
const git_index_entry * entry ;
164
168
const git_index_reuc_entry * reuc ;
165
169
166
- cl_git_pass (merge_trivial (& result , "trivial-6" , "trivial-6-branch" ));
170
+ cl_git_pass (merge_trivial (& result , "trivial-6" , "trivial-6-branch" , false ));
167
171
168
172
cl_assert ((entry = git_index_get_bypath (result , "removed-in-both.txt" , 0 )) == NULL );
169
173
cl_assert (git_index_reuc_entrycount (result ) == 1 );
@@ -181,7 +185,7 @@ void test_merge_trees_trivial__8(void)
181
185
const git_index_entry * entry ;
182
186
const git_index_reuc_entry * reuc ;
183
187
184
- cl_git_pass (merge_trivial (& result , "trivial-8" , "trivial-8-branch" ));
188
+ cl_git_pass (merge_trivial (& result , "trivial-8" , "trivial-8-branch" , false ));
185
189
186
190
cl_assert ((entry = git_index_get_bypath (result , "removed-in-8.txt" , 0 )) == NULL );
187
191
@@ -199,7 +203,7 @@ void test_merge_trees_trivial__7(void)
199
203
git_index * result ;
200
204
const git_index_entry * entry ;
201
205
202
- cl_git_pass (merge_trivial (& result , "trivial-7" , "trivial-7-branch" ));
206
+ cl_git_pass (merge_trivial (& result , "trivial-7" , "trivial-7-branch" , false ));
203
207
204
208
cl_assert ((entry = git_index_get_bypath (result , "removed-in-7.txt" , 0 )) == NULL );
205
209
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -218,7 +222,7 @@ void test_merge_trees_trivial__10(void)
218
222
const git_index_entry * entry ;
219
223
const git_index_reuc_entry * reuc ;
220
224
221
- cl_git_pass (merge_trivial (& result , "trivial-10" , "trivial-10-branch" ));
225
+ cl_git_pass (merge_trivial (& result , "trivial-10" , "trivial-10-branch" , false ));
222
226
223
227
cl_assert ((entry = git_index_get_bypath (result , "removed-in-10-branch.txt" , 0 )) == NULL );
224
228
@@ -236,7 +240,7 @@ void test_merge_trees_trivial__9(void)
236
240
git_index * result ;
237
241
const git_index_entry * entry ;
238
242
239
- cl_git_pass (merge_trivial (& result , "trivial-9" , "trivial-9-branch" ));
243
+ cl_git_pass (merge_trivial (& result , "trivial-9" , "trivial-9-branch" , false ));
240
244
241
245
cl_assert ((entry = git_index_get_bypath (result , "removed-in-9-branch.txt" , 0 )) == NULL );
242
246
cl_assert (git_index_reuc_entrycount (result ) == 0 );
@@ -255,7 +259,7 @@ void test_merge_trees_trivial__13(void)
255
259
const git_index_entry * entry ;
256
260
git_oid expected_oid ;
257
261
258
- cl_git_pass (merge_trivial (& result , "trivial-13" , "trivial-13-branch" ));
262
+ cl_git_pass (merge_trivial (& result , "trivial-13" , "trivial-13-branch" , false ));
259
263
260
264
cl_assert (entry = git_index_get_bypath (result , "modified-in-13.txt" , 0 ));
261
265
cl_git_pass (git_oid__fromstr (& expected_oid , "1cff9ec6a47a537380dedfdd17c9e76d74259a2b" , GIT_OID_SHA1 ));
@@ -274,7 +278,7 @@ void test_merge_trees_trivial__14(void)
274
278
const git_index_entry * entry ;
275
279
git_oid expected_oid ;
276
280
277
- cl_git_pass (merge_trivial (& result , "trivial-14" , "trivial-14-branch" ));
281
+ cl_git_pass (merge_trivial (& result , "trivial-14" , "trivial-14-branch" , false ));
278
282
279
283
cl_assert (entry = git_index_get_bypath (result , "modified-in-14-branch.txt" , 0 ));
280
284
cl_git_pass (git_oid__fromstr (& expected_oid , "26153a3ff3649b6c2bb652d3f06878c6e0a172f9" , GIT_OID_SHA1 ));
@@ -292,7 +296,7 @@ void test_merge_trees_trivial__11(void)
292
296
git_index * result ;
293
297
const git_index_entry * entry ;
294
298
295
- cl_git_pass (merge_trivial (& result , "trivial-11" , "trivial-11-branch" ));
299
+ cl_git_pass (merge_trivial (& result , "trivial-11" , "trivial-11-branch" , false ));
296
300
297
301
cl_assert ((entry = git_index_get_bypath (result , "modified-in-both.txt" , 0 )) == NULL );
298
302
cl_assert (git_index_reuc_entrycount (result ) == 0 );
0 commit comments