forked from RogerGee/php-git2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.h
510 lines (442 loc) · 14.5 KB
/
merge.h
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
/*
* merge.h
*
* Copyright (C) Roger P. Gee
*/
#ifndef PHPGIT2_MERGE_H
#define PHPGIT2_MERGE_H
#include "checkout.h"
#include "index.h"
namespace php_git2
{
// Provide a type for converting a PHP array into a git_merge_options
// struct.
class php_git_merge_options:
public php_option_array
{
public:
php_git_merge_options()
{
git_merge_init_options(&opts,GIT_MERGE_OPTIONS_VERSION);
}
git_merge_options* byval_git2()
{
if (!is_null()) {
array_wrapper arr(value);
GIT2_ARRAY_LOOKUP_LONG(arr,flags,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,rename_threshold,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,target_limit,opts);
// TODO Handle 'metric' member.
GIT2_ARRAY_LOOKUP_LONG(arr,recursion_limit,opts);
GIT2_ARRAY_LOOKUP_STRING(arr,default_driver,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,file_favor,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,file_flags,opts);
return &opts;
}
return nullptr;
}
private:
git_merge_options opts;
php_git_strarray_byval_array strarray;
};
// Provide type for git_merge_file_options.
class php_git_merge_file_options:
public php_option_array
{
public:
php_git_merge_file_options()
{
git_merge_file_init_options(&opts,GIT_MERGE_FILE_OPTIONS_VERSION);
}
const git_merge_file_options* byval_git2()
{
if (!is_null()) {
array_wrapper arr(value);
GIT2_ARRAY_LOOKUP_STRING(arr,ancestor_label,opts);
GIT2_ARRAY_LOOKUP_STRING(arr,our_label,opts);
GIT2_ARRAY_LOOKUP_STRING(arr,their_label,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,favor,opts);
GIT2_ARRAY_LOOKUP_LONG(arr,flags,opts);
return &opts;
}
return nullptr;
}
private:
git_merge_file_options opts;
};
// Provide type for git_merge_file_input.
class php_git_merge_file_input:
public php_option_array
{
public:
php_git_merge_file_input()
{
git_merge_file_init_input(&input,GIT_MERGE_FILE_INPUT_VERSION);
}
const git_merge_file_input* byval_git2()
{
if (!is_null()) {
array_wrapper arr(value);
GIT2_ARRAY_LOOKUP_STRING_WITH_LENGTH(arr,ptr,size,input);
GIT2_ARRAY_LOOKUP_STRING_NULLABLE(arr,path,input);
GIT2_ARRAY_LOOKUP_LONG(arr,mode,input);
return &input;
}
return nullptr;
}
private:
git_merge_file_input input;
};
// Provide type for git_merge_file_result conversion to PHP array.
class php_git_merge_file_result_ref
{
public:
~php_git_merge_file_result_ref()
{
git_merge_file_result_free(&result);
}
git_merge_file_result* byval_git2()
{
return &result;
}
void ret(zval* return_value)
{
convert_merge_file_result(return_value,&result);
}
private:
git_merge_file_result result;
};
// Define array types.
using php_git_merge_annot_array = php_array<
php_resource<php_git_annotated_commit>,
const git_annotated_commit*
>;
using php_git_merge_annot_array_length = connector_wrapper<
php_array_length_connector<
size_t,
php_git2::php_git_merge_annot_array
>
>;
} // namespace php_git2
static constexpr auto ZIF_GIT_MERGE = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_repository*,
const git_annotated_commit**,
size_t,
const git_merge_options*,
const git_checkout_options*>::func<git_merge>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_git_merge_annot_array_length,
php_git2::php_git_merge_annot_array,
php_git2::php_git_merge_options,
php_git2::php_git_checkout_options
>,
-1,
php_git2::sequence<0,2,3,4>,
php_git2::sequence<0,2,1,3,4>
>;
static constexpr auto ZIF_GIT_MERGE_ANALYSIS = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_merge_analysis_t*,
git_merge_preference_t*,
git_repository*,
const git_annotated_commit**,
size_t>::func<git_merge_analysis>,
php_git2::local_pack<
php_git2::php_long_ref<git_merge_analysis_t>,
php_git2::php_long_out<git_merge_preference_t>,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_git_merge_annot_array_length,
php_git2::php_git_merge_annot_array
>,
1,
php_git2::sequence<1,2,4>,
php_git2::sequence<0,1,2,4,3>
>;
ZEND_BEGIN_ARG_INFO_EX(git_merge_analysis_arginfo,0,0,3)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO()
static constexpr auto ZIF_GIT_MERGE_BASE = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_oid*,
git_repository*,
const git_oid*,
const git_oid*>::func<git_merge_base>,
php_git2::local_pack<
php_git2::php_git_oid,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_git_oid_fromstr,
php_git2::php_git_oid_fromstr
>,
1,
php_git2::sequence<1,2,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_MERGE_BASE_MANY = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_oid*,
git_repository*,
size_t,
const git_oid[]>::func<git_merge_base_many>,
php_git2::local_pack<
php_git2::php_git_oid,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::connector_wrapper<
php_git2::php_array_length_connector<
size_t,
php_git2::php_git_oid_byval_array
>
>,
php_git2::php_git_oid_byval_array
>,
1,
php_git2::sequence<1,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_MERGE_BASE_OCTOPUS = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_oid*,
git_repository*,
size_t,
const git_oid[]>::func<git_merge_base_octopus>,
php_git2::local_pack<
php_git2::php_git_oid,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::connector_wrapper<
php_git2::php_array_length_connector<
size_t,
php_git2::php_git_oid_byval_array
>
>,
php_git2::php_git_oid_byval_array
>,
1,
php_git2::sequence<1,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_MERGE_BASES = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_oidarray*,
git_repository*,
const git_oid*,
const git_oid*>::func<git_merge_bases>,
php_git2::local_pack<
php_git2::php_git_oidarray,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_git_oid_fromstr,
php_git2::php_git_oid_fromstr
>,
1,
php_git2::sequence<1,2,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_MERGE_BASES_MANY = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_oidarray*,
git_repository*,
size_t,
const git_oid[]>::func<git_merge_bases_many>,
php_git2::local_pack<
php_git2::php_git_oidarray,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::connector_wrapper<
php_git2::php_array_length_connector<
size_t,
php_git2::php_git_oid_byval_array
>
>,
php_git2::php_git_oid_byval_array
>,
1,
php_git2::sequence<1,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_MERGE_COMMITS = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_index**,
git_repository*,
const git_commit*,
const git_commit*,
const git_merge_options*>::func<git_merge_commits>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_index>,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_resource<php_git2::php_git_commit>,
php_git2::php_resource<php_git2::php_git_commit>,
php_git2::php_git_merge_options
>,
1,
php_git2::sequence<1,2,3,4>,
php_git2::sequence<0,1,2,3,4>
>;
/*static constexpr auto ZIF_GIT_MERGE_DRIVER_LOOKUP = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_lookup>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_REGISTER = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_register>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_SOURCE_ANCESTOR = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_source_ancestor>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_SOURCE_FILE_OPTIONS = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_source_file_options>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_SOURCE_OURS = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_source_ours>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_SOURCE_REPO = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_source_repo>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_SOURCE_THEIRS = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_source_theirs>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
static constexpr auto ZIF_GIT_MERGE_DRIVER_UNREGISTER = zif_php_git2_function<
php_git2::func_wrapper<
>::func<git_merge_driver_unregister>,
php_git2::local_pack<
>,
-1,
php_git2::sequence<>,
php_git2::sequence<>
>;
*/
static constexpr auto ZIF_GIT_MERGE_FILE = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_merge_file_result*,
const git_merge_file_input*,
const git_merge_file_input*,
const git_merge_file_input*,
const git_merge_file_options*>::func<git_merge_file>,
php_git2::local_pack<
php_git2::php_git_merge_file_result_ref,
php_git2::php_git_merge_file_input,
php_git2::php_git_merge_file_input,
php_git2::php_git_merge_file_input,
php_git2::php_git_merge_file_options
>,
1,
php_git2::sequence<1,2,3,4>,
php_git2::sequence<0,1,2,3,4>
>;
static constexpr auto ZIF_GIT_MERGE_FILE_FROM_INDEX = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_merge_file_result*,
git_repository*,
const git_index_entry*,
const git_index_entry*,
const git_index_entry*,
const git_merge_file_options*>::func<git_merge_file_from_index>,
php_git2::local_pack<
php_git2::php_git_merge_file_result_ref,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_git_index_entry,
php_git2::php_git_index_entry,
php_git2::php_git_index_entry,
php_git2::php_git_merge_file_options
>,
1,
php_git2::sequence<1,2,3,4,5>,
php_git2::sequence<0,1,2,3,4,5>
>;
static constexpr auto ZIF_GIT_MERGE_TREES = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_index**,
git_repository*,
const git_tree*,
const git_tree*,
const git_tree*,
const git_merge_options*>::func<git_merge_trees>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_index>,
php_git2::php_resource<php_git2::php_git_repository>,
php_git2::php_resource_nullable<php_git2::php_git_tree>,
php_git2::php_resource<php_git2::php_git_tree>,
php_git2::php_resource<php_git2::php_git_tree>,
php_git2::php_git_merge_options
>,
1,
php_git2::sequence<1,2,3,4,5>,
php_git2::sequence<0,1,2,3,4,5>
>;
#define GIT_MERGE_FE \
PHP_GIT2_FE(git_merge,ZIF_GIT_MERGE,NULL) \
PHP_GIT2_FE(git_merge_analysis,ZIF_GIT_MERGE_ANALYSIS,git_merge_analysis_arginfo) \
PHP_GIT2_FE(git_merge_base,ZIF_GIT_MERGE_BASE,NULL) \
PHP_GIT2_FE(git_merge_base_many,ZIF_GIT_MERGE_BASE_MANY,NULL) \
PHP_GIT2_FE(git_merge_base_octopus,ZIF_GIT_MERGE_BASE_OCTOPUS,NULL) \
PHP_GIT2_FE(git_merge_bases,ZIF_GIT_MERGE_BASES,NULL) \
PHP_GIT2_FE(git_merge_bases_many,ZIF_GIT_MERGE_BASES_MANY,NULL) \
PHP_GIT2_FE(git_merge_commits,ZIF_GIT_MERGE_COMMITS,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_lookup,ZIF_GIT_MERGE_DRIVER_LOOKUP,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_register,ZIF_GIT_MERGE_DRIVER_REGISTER,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_source_ancestor,ZIF_GIT_MERGE_DRIVER_SOURCE_ANCESTOR,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_source_file_options,ZIF_GIT_MERGE_DRIVER_SOURCE_FILE_OPTIONS,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_source_ours,ZIF_GIT_MERGE_DRIVER_SOURCE_OURS,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_source_repo,ZIF_GIT_MERGE_DRIVER_SOURCE_REPO,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_source_theirs,ZIF_GIT_MERGE_DRIVER_SOURCE_THEIRS,NULL) \
PHP_GIT2_UNIMPLEMENTED(git_merge_driver_unregister,ZIF_GIT_MERGE_DRIVER_UNREGISTER,NULL) \
PHP_GIT2_FE(git_merge_file,ZIF_GIT_MERGE_FILE,NULL) \
PHP_GIT2_FE(git_merge_file_from_index,ZIF_GIT_MERGE_FILE_FROM_INDEX,NULL) \
PHP_GIT2_FE(git_merge_trees,ZIF_GIT_MERGE_TREES,NULL)
#endif
/*
* Local Variables:
* mode:c++
* indent-tabs-mode:nil
* tab-width:4
* End:
*/