-
Notifications
You must be signed in to change notification settings - Fork 890
/
NativeMethods.cs
2112 lines (1683 loc) · 113 KB
/
NativeMethods.cs
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core.Handles;
// Restrict the set of directories where the native library is loaded from to safe directories.
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.ApplicationDirectory | DllImportSearchPath.SafeDirectories)]
namespace LibGit2Sharp.Core
{
internal static class NativeMethods
{
public const uint GIT_PATH_MAX = 4096;
private const string libgit2 = NativeDllName.Name;
// An object tied to the lifecycle of the NativeMethods static class.
// This will handle initialization and shutdown of the underlying
// native library.
private static NativeShutdownObject shutdownObject;
static NativeMethods()
{
if (Platform.IsRunningOnNetFramework() || Platform.IsRunningOnNetCore())
{
// Use NativeLibrary when available.
if (!TryUseNativeLibrary())
{
// NativeLibrary is not available, fall back.
// Use GlobalSettings.NativeLibraryPath when set.
// Try to load the .dll from the path explicitly.
// If this call succeeds further DllImports will find the library loaded and not attempt to load it again.
// If it fails the next DllImport will load the library from safe directories.
string nativeLibraryPath = GetGlobalSettingsNativeLibraryPath();
if (nativeLibraryPath != null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
LoadWindowsLibrary(nativeLibraryPath);
}
else
{
LoadUnixLibrary(nativeLibraryPath, RTLD_NOW);
}
}
}
}
InitializeNativeLibrary();
}
private static string GetGlobalSettingsNativeLibraryPath()
{
string nativeLibraryDir = GlobalSettings.GetAndLockNativeLibraryPath();
if (nativeLibraryDir == null)
{
return null;
}
return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension());
}
#if NETSTANDARD
private static bool TryUseNativeLibrary() => false;
#else
private static bool TryUseNativeLibrary()
{
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly, ResolveDll);
return true;
}
private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{
IntPtr handle = IntPtr.Zero;
if (libraryName == libgit2)
{
// Use GlobalSettings.NativeLibraryPath when set.
string nativeLibraryPath = GetGlobalSettingsNativeLibraryPath();
if (nativeLibraryPath != null && NativeLibrary.TryLoad(nativeLibraryPath, out handle))
{
return handle;
}
// Use Default DllImport resolution.
if (NativeLibrary.TryLoad(libraryName, assembly, searchPath, out handle))
{
return handle;
}
// We carry a number of .so files for Linux which are linked against various
// libc/OpenSSL libraries. Try them out.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// The libraries are located at 'runtimes/<rid>/native/lib{libraryName}.so'
// The <rid> ends with the processor architecture. e.g. fedora-x64.
string assemblyDirectory = Path.GetDirectoryName(typeof(NativeMethods).Assembly.Location);
string processorArchitecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
string runtimesDirectory = Path.Combine(assemblyDirectory, "runtimes");
if (Directory.Exists(runtimesDirectory))
{
foreach (var runtimeFolder in Directory.GetDirectories(runtimesDirectory, $"*-{processorArchitecture}"))
{
string libPath = Path.Combine(runtimeFolder, "native", $"lib{libraryName}.so");
if (NativeLibrary.TryLoad(libPath, out handle))
{
return handle;
}
}
}
}
}
return handle;
}
#endif
public const int RTLD_NOW = 0x002;
[DllImport("libdl", EntryPoint = "dlopen")]
private static extern IntPtr LoadUnixLibrary(string path, int flags);
[DllImport("kernel32", EntryPoint = "LoadLibrary")]
private static extern IntPtr LoadWindowsLibrary(string path);
// Avoid inlining this method because otherwise mono's JITter may try
// to load the library _before_ we've configured the path.
[MethodImpl(MethodImplOptions.NoInlining)]
private static void InitializeNativeLibrary()
{
int initCounter;
try
{
}
finally // avoid thread aborts
{
// Initialization can be called multiple times as long as there is a corresponding shutdown to each initialization.
initCounter = git_libgit2_init();
shutdownObject = new NativeShutdownObject();
}
// Configure the OpenSSL locking on the first initialization of the library in the current process.
if (initCounter == 1)
{
git_openssl_set_locking();
}
}
// Shutdown the native library in a finalizer.
private sealed class NativeShutdownObject : CriticalFinalizerObject
{
~NativeShutdownObject()
{
git_libgit2_shutdown();
}
}
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe GitError* git_error_last();
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_error_set_str(
GitErrorCategory error_class,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string errorString);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_error_set_oom();
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UInt32 git_blame_get_hunk_count(git_blame* blame);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_blame_hunk* git_blame_get_hunk_byindex(
git_blame* blame, UInt32 index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blame_file(
out git_blame* blame,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path,
git_blame_options options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_blame_free(git_blame* blame);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_from_disk(
ref GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_from_workdir(
ref GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath relative_path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_from_stream(
out IntPtr stream,
git_repository* repositoryPtr,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string hintpath);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_blob_create_from_stream_commit(
ref GitOid oid,
IntPtr stream);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_filtered_content(
GitBuf buf,
git_object* blob,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string as_path,
[MarshalAs(UnmanagedType.Bool)] bool check_for_binary_data);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe IntPtr git_blob_rawcontent(git_object* blob);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe Int64 git_blob_rawsize(git_object* blob);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_branch_create_from_annotated(
out git_reference* ref_out,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string branch_name,
git_annotated_commit* target,
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_branch_delete(
git_reference* reference);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int branch_foreach_callback(
IntPtr branch_name,
GitBranchType branch_type,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_branch_iterator_free(
IntPtr iterator);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_branch_iterator_new(
out IntPtr iter_out,
IntPtr repo,
GitBranchType branch_type);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_branch_move(
out git_reference* ref_out,
git_reference* reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_branch_name,
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_branch_next(
out IntPtr ref_out,
out GitBranchType type_out,
IntPtr iter);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_branch_remote_name(
GitBuf buf,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string canonical_branch_name);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int commit_signing_callback(
IntPtr signature,
IntPtr signature_field,
IntPtr commit_content,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_init(
out git_rebase* rebase,
git_repository* repo,
git_annotated_commit* branch,
git_annotated_commit* upstream,
git_annotated_commit* onto,
GitRebaseOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_open(
out git_rebase* rebase,
git_repository* repo,
GitRebaseOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_rebase_operation_entrycount(
git_rebase* rebase);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_rebase_operation_current(
git_rebase* rebase);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_rebase_operation* git_rebase_operation_byindex(
git_rebase* rebase,
UIntPtr index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_next(
out git_rebase_operation* operation,
git_rebase* rebase);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_commit(
ref GitOid id,
git_rebase* rebase,
git_signature* author,
git_signature* committer,
IntPtr message_encoding,
IntPtr message);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_abort(
git_rebase* rebase);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_rebase_finish(
git_rebase* repo,
git_signature* signature);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_rebase_free(git_rebase* rebase);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_remote_rename(
ref GitStrArray problems,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string old_name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_name);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int git_remote_rename_problem_cb(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] string problematic_refspec,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_branch_upstream_name(
GitBuf buf,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string referenceName);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_buf_dispose(GitBuf buf);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_checkout_tree(
git_repository* repo,
git_object* treeish,
ref GitCheckoutOpts opts);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_checkout_index(
git_repository* repo,
git_object* treeish,
ref GitCheckoutOpts opts);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_clone(
out git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string origin_url,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath workdir_path,
ref GitCloneOptions opts);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_signature* git_commit_author(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_signature* git_commit_committer(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_commit_create_from_ids(
out GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string updateRef,
git_signature* author,
git_signature* committer,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string encoding,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message,
ref GitOid tree,
UIntPtr parentCount,
[MarshalAs(UnmanagedType.LPArray)][In] IntPtr[] parents);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_commit_create_buffer(
GitBuf res,
git_repository* repo,
git_signature* author,
git_signature* committer,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string encoding,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message,
git_object* tree,
UIntPtr parent_count,
IntPtr* parents /* git_commit** originally */);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_commit_create_with_signature(
out GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string commit_content,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string signature_field);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]
internal static extern unsafe string git_commit_message(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]
internal static extern unsafe string git_commit_summary(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]
internal static extern unsafe string git_commit_message_encoding(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_oid* git_commit_parent_id(git_object* commit, uint n);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe uint git_commit_parentcount(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_oid* git_commit_tree_id(git_object* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_commit_extract_signature(
GitBuf signature,
GitBuf signed_data,
git_repository* repo,
ref GitOid commit_id,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string field);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_delete_entry(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_lock(out IntPtr txn, git_config* config);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_delete_multivar(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string regexp);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_set_multivar(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string regexp,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string value);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_find_global(GitBuf global_config_path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_find_system(GitBuf system_config_path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_find_xdg(GitBuf xdg_config_path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_find_programdata(GitBuf programdata_config_path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_config_free(git_config* cfg);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_config_entry_free(GitConfigEntry* entry);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_get_entry(
out GitConfigEntry* entry,
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_add_file_ondisk(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path,
uint level,
git_repository* repo,
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_new(out git_config* cfg);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_open_level(
out git_config* cfg,
git_config* parent,
uint level);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_parse_bool(
[MarshalAs(UnmanagedType.Bool)] out bool value,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string valueToParse);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_parse_int32(
[MarshalAs(UnmanagedType.I4)] out int value,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string valueToParse);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_parse_int64(
[MarshalAs(UnmanagedType.I8)] out long value,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string valueToParse);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_set_bool(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.Bool)] bool value);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_set_int32(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
int value);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_set_int64(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
long value);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_set_string(
git_config* cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int config_foreach_callback(
IntPtr entry,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_foreach(
git_config* cfg,
config_foreach_callback callback,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_iterator_glob_new(
out IntPtr iter,
IntPtr cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string regexp);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_config_next(
out IntPtr entry,
IntPtr iter);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_config_iterator_free(IntPtr iter);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_config_snapshot(out git_config* @out, git_config* config);
// Ordinarily we would decorate the `url` parameter with the StrictUtf8Marshaler like we do everywhere
// else, but apparently doing a native->managed callback with the 64-bit version of CLR 2.0 can
// sometimes vomit when using a custom IMarshaler. So yeah, don't do that. If you need the url,
// call StrictUtf8Marshaler.FromNative manually. See the discussion here:
// http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/1eb746c6-d695-4632-8a9e-16c4fa98d481
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int git_cred_acquire_cb(
out IntPtr cred,
IntPtr url,
IntPtr username_from_url,
GitCredentialType allowed_types,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_cred_default_new(out IntPtr cred);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_cred_userpass_plaintext_new(
out IntPtr cred,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string username,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string password);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_cred_free(IntPtr cred);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_describe_commit(
out git_describe_result* describe,
git_object* committish,
ref GitDescribeOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_describe_format(
GitBuf buf,
git_describe_result* describe,
ref GitDescribeFormatOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_describe_result_free(git_describe_result* describe);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_diff_free(git_diff* diff);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_tree_to_tree(
out git_diff* diff,
git_repository* repo,
git_object* oldTree,
git_object* newTree,
GitDiffOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_tree_to_index(
out git_diff* diff,
git_repository* repo,
git_object* oldTree,
git_index* index,
GitDiffOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_merge(
git_diff* onto,
git_diff* from);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_index_to_workdir(
out git_diff* diff,
git_repository* repo,
git_index* index,
GitDiffOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_tree_to_workdir(
out git_diff* diff,
git_repository* repo,
git_object* oldTree,
GitDiffOptions options);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int git_diff_file_cb(
[In] git_diff_delta* delta,
float progress,
IntPtr payload);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int git_diff_hunk_cb(
[In] git_diff_delta* delta,
[In] GitDiffHunk hunk,
IntPtr payload);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int git_diff_line_cb(
[In] git_diff_delta* delta,
[In] GitDiffHunk hunk,
[In] GitDiffLine line,
IntPtr payload);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int git_diff_binary_cb(
[In] git_diff_delta* delta,
[In] GitDiffBinary binary,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_blobs(
git_object* oldBlob,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string old_as_path,
git_object* newBlob,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_as_path,
GitDiffOptions options,
git_diff_file_cb fileCallback,
git_diff_binary_cb binaryCallback,
git_diff_hunk_cb hunkCallback,
git_diff_line_cb lineCallback,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_foreach(
git_diff* diff,
git_diff_file_cb fileCallback,
git_diff_binary_cb binaryCallback,
git_diff_hunk_cb hunkCallback,
git_diff_line_cb lineCallback,
IntPtr payload);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_diff_find_similar(
git_diff* diff,
GitDiffFindOptions options);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_diff_num_deltas(git_diff* diff);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_diff_delta* git_diff_get_delta(git_diff* diff, UIntPtr idx);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_filter_register(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
IntPtr gitFilter, int priority);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_filter_unregister(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_filter_source_mode(git_filter_source* source);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_features();
#region git_libgit2_opts
// Bindings for git_libgit2_opts(int option, ...):
// Currently only GIT_OPT_GET_SEARCH_PATH and GIT_OPT_SET_SEARCH_PATH are supported,
// but other overloads could be added using a similar pattern.
// CallingConvention.Cdecl is used to allow binding the the C varargs signature, and each possible call signature must be enumerated.
// __argslist was an option, but is an undocumented feature that should likely not be used here.
// git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, uint level, GitBuf buf);
// git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, uint level,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
// git_libgit2_opts(GIT_OPT_ENABLE_*, int enabled)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, int enabled);
// git_libgit2_opts(GIT_OPT_SET_USER_AGENT, const char *path)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
// git_libgit2_opts(GIT_OPT_GET_USER_AGENT, git_buf *buf)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, GitBuf buf);
// git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, const char **extensions, size_t len)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, IntPtr extensions, UIntPtr len);
// git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, git_strarray *out)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_libgit2_opts(int option, out GitStrArray extensions);
#endregion
#region git_libgit2_opts_osxarm64
// For RID osx-arm64 the calling convention is different: we need to pad out to 8 arguments before varargs
// (see discussion at https://github.com/dotnet/runtime/issues/48796)
// git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, uint level, GitBuf buf);
// git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, uint level,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
// git_libgit2_opts(GIT_OPT_ENABLE_*, int enabled)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, int enabled);
// git_libgit2_opts(GIT_OPT_SET_USER_AGENT, const char *path)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
// git_libgit2_opts(GIT_OPT_GET_USER_AGENT, git_buf *buf)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, GitBuf buf);
// git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, const char **extensions, size_t len)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, IntPtr extensions, UIntPtr len);
// git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, git_strarray *out)
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl, EntryPoint = "git_libgit2_opts")]
internal static extern int git_libgit2_opts_osxarm64(int option, IntPtr nop2, IntPtr nop3, IntPtr nop4, IntPtr nop5, IntPtr nop6, IntPtr nop7, IntPtr nop8, out GitStrArray extensions);
#endregion
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_graph_ahead_behind(out UIntPtr ahead, out UIntPtr behind, git_repository* repo, ref GitOid one, ref GitOid two);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_graph_descendant_of(
git_repository* repo,
ref GitOid commit,
ref GitOid ancestor);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_ignore_add_rule(
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string rules);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_ignore_clear_internal_rules(git_repository* repo);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_ignore_path_is_ignored(
out int ignored,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_add_bypath(
git_index* index,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_add(
git_index* index,
git_index_entry* entry);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_conflict_get(
out git_index_entry* ancestor,
out git_index_entry* ours,
out git_index_entry* theirs,
git_index* index,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_conflict_iterator_new(
out git_index_conflict_iterator* iterator,
git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_conflict_next(
out git_index_entry* ancestor,
out git_index_entry* ours,
out git_index_entry* theirs,
git_index_conflict_iterator* iterator);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_index_conflict_iterator_free(
git_index_conflict_iterator* iterator);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_index_entrycount(git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_entry_stage(git_index_entry* indexentry);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_index_free(git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_index_entry* git_index_get_byindex(git_index* index, UIntPtr n);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_index_entry* git_index_get_bypath(
git_index* index,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path,
int stage);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_has_conflicts(git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_index_name_entrycount(git_index* handle);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_index_name_entry* git_index_name_get_byindex(git_index* handle, UIntPtr n);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_open(
out git_index* index,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath indexpath);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_read(
git_index* index,
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_remove_bypath(
git_index* index,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe UIntPtr git_index_reuc_entrycount(git_index* handle);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_index_reuc_entry* git_index_reuc_get_byindex(git_index* handle, UIntPtr n);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_index_reuc_entry* git_index_reuc_get_bypath(
git_index* handle,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string path);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_write(git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_write_tree(out GitOid treeOid, git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_write_tree_to(out GitOid treeOid, git_index* index, git_repository* repo);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_read_tree(git_index* index, git_object* tree);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_index_clear(git_index* index);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_merge_base_many(
out GitOid mergeBase,
git_repository* repo,
int length,
[In] GitOid[] input_array);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_merge_base_octopus(
out GitOid mergeBase,
git_repository* repo,
int length,
[In] GitOid[] input_array);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_annotated_commit_from_ref(
out git_annotated_commit* annotatedCommit,
git_repository* repo,
git_reference* reference);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_annotated_commit_from_fetchhead(
out git_annotated_commit* annotatedCommit,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string branch_name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_url,
ref GitOid oid);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_annotated_commit_from_revspec(
out git_annotated_commit* annotatedCommit,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string revspec);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_annotated_commit_lookup(
out git_annotated_commit* annotatedCommit,
git_repository* repo,
ref GitOid id);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_oid* git_annotated_commit_id(
git_annotated_commit* annotatedCommit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_merge(
git_repository* repo,
[In] IntPtr[] their_heads,
UIntPtr their_heads_len,
ref GitMergeOpts merge_opts,
ref GitCheckoutOpts checkout_opts);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_merge_commits(
out git_index* index,
git_repository* repo,
git_object* our_commit,
git_object* their_commit,
ref GitMergeOpts merge_opts);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_merge_analysis(
out GitMergeAnalysis status_out,
out GitMergePreference preference_out,
git_repository* repo,
[In] IntPtr[] their_heads,
int their_heads_len);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_annotated_commit_free(git_annotated_commit* commit);
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_message_prettify(