@@ -14,6 +14,9 @@ namespace LibGit2Sharp.Core
14
14
{
15
15
internal class Proxy
16
16
{
17
+ internal static readonly bool isOSXArm64 = RuntimeInformation . ProcessArchitecture == Architecture . Arm64
18
+ && RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
19
+
17
20
#region git_blame_
18
21
19
22
public static unsafe BlameHandle git_blame_file (
@@ -3408,7 +3411,11 @@ public static string git_libgit2_opts_get_search_path(ConfigurationLevel level)
3408
3411
3409
3412
using ( var buf = new GitBuf ( ) )
3410
3413
{
3411
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetSearchPath , ( uint ) level , buf ) ;
3414
+ int res ;
3415
+ if ( isOSXArm64 )
3416
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . GetSearchPath , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , ( uint ) level , buf ) ;
3417
+ else
3418
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetSearchPath , ( uint ) level , buf ) ;
3412
3419
Ensure . ZeroResult ( res ) ;
3413
3420
3414
3421
path = LaxUtf8Marshaler . FromNative ( buf . ptr ) ?? string . Empty ;
@@ -3419,7 +3426,10 @@ public static string git_libgit2_opts_get_search_path(ConfigurationLevel level)
3419
3426
3420
3427
public static void git_libgit2_opts_enable_strict_hash_verification ( bool enabled )
3421
3428
{
3422
- NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableStrictHashVerification , enabled ? 1 : 0 ) ;
3429
+ if ( isOSXArm64 )
3430
+ NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . EnableStrictHashVerification , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , enabled ? 1 : 0 ) ;
3431
+ else
3432
+ NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableStrictHashVerification , enabled ? 1 : 0 ) ;
3423
3433
}
3424
3434
3425
3435
/// <summary>
@@ -3432,7 +3442,11 @@ public static void git_libgit2_opts_enable_strict_hash_verification(bool enabled
3432
3442
/// </param>
3433
3443
public static void git_libgit2_opts_set_search_path ( ConfigurationLevel level , string path )
3434
3444
{
3435
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetSearchPath , ( uint ) level , path ) ;
3445
+ int res ;
3446
+ if ( isOSXArm64 )
3447
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . SetSearchPath , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , ( uint ) level , path ) ;
3448
+ else
3449
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetSearchPath , ( uint ) level , path ) ;
3436
3450
Ensure . ZeroResult ( res ) ;
3437
3451
}
3438
3452
@@ -3443,7 +3457,11 @@ public static void git_libgit2_opts_set_search_path(ConfigurationLevel level, st
3443
3457
public static void git_libgit2_opts_set_enable_caching ( bool enabled )
3444
3458
{
3445
3459
// libgit2 expects non-zero value for true
3446
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableCaching , enabled ? 1 : 0 ) ;
3460
+ int res ;
3461
+ if ( isOSXArm64 )
3462
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . EnableCaching , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , enabled ? 1 : 0 ) ;
3463
+ else
3464
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableCaching , enabled ? 1 : 0 ) ;
3447
3465
Ensure . ZeroResult ( res ) ;
3448
3466
}
3449
3467
@@ -3454,7 +3472,11 @@ public static void git_libgit2_opts_set_enable_caching(bool enabled)
3454
3472
public static void git_libgit2_opts_set_enable_ofsdelta ( bool enabled )
3455
3473
{
3456
3474
// libgit2 expects non-zero value for true
3457
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableOfsDelta , enabled ? 1 : 0 ) ;
3475
+ int res ;
3476
+ if ( isOSXArm64 )
3477
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . EnableOfsDelta , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , enabled ? 1 : 0 ) ;
3478
+ else
3479
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableOfsDelta , enabled ? 1 : 0 ) ;
3458
3480
Ensure . ZeroResult ( res ) ;
3459
3481
}
3460
3482
@@ -3465,7 +3487,11 @@ public static void git_libgit2_opts_set_enable_ofsdelta(bool enabled)
3465
3487
public static void git_libgit2_opts_set_enable_strictobjectcreation ( bool enabled )
3466
3488
{
3467
3489
// libgit2 expects non-zero value for true
3468
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableStrictObjectCreation , enabled ? 1 : 0 ) ;
3490
+ int res ;
3491
+ if ( isOSXArm64 )
3492
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . EnableStrictObjectCreation , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , enabled ? 1 : 0 ) ;
3493
+ else
3494
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . EnableStrictObjectCreation , enabled ? 1 : 0 ) ;
3469
3495
Ensure . ZeroResult ( res ) ;
3470
3496
}
3471
3497
@@ -3476,7 +3502,11 @@ public static void git_libgit2_opts_set_enable_strictobjectcreation(bool enabled
3476
3502
/// <param name="userAgent">The user-agent string to use</param>
3477
3503
public static void git_libgit2_opts_set_user_agent ( string userAgent )
3478
3504
{
3479
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetUserAgent , userAgent ) ;
3505
+ int res ;
3506
+ if ( isOSXArm64 )
3507
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . SetUserAgent , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , userAgent ) ;
3508
+ else
3509
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetUserAgent , userAgent ) ;
3480
3510
Ensure . ZeroResult ( res ) ;
3481
3511
}
3482
3512
@@ -3492,7 +3522,11 @@ public static string git_libgit2_opts_get_user_agent()
3492
3522
3493
3523
using ( var buf = new GitBuf ( ) )
3494
3524
{
3495
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetUserAgent , buf ) ;
3525
+ int res ;
3526
+ if ( isOSXArm64 )
3527
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . GetUserAgent , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , buf ) ;
3528
+ else
3529
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetUserAgent , buf ) ;
3496
3530
Ensure . ZeroResult ( res ) ;
3497
3531
3498
3532
userAgent = LaxUtf8Marshaler . FromNative ( buf . ptr ) ?? string . Empty ;
@@ -3505,7 +3539,11 @@ public static void git_libgit2_opts_set_extensions(string[] extensions)
3505
3539
{
3506
3540
using ( var array = GitStrArrayManaged . BuildFrom ( extensions ) )
3507
3541
{
3508
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetExtensions , array . Array . Strings , array . Array . Count ) ;
3542
+ int res ;
3543
+ if ( isOSXArm64 )
3544
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . SetExtensions , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , array . Array . Strings , array . Array . Count ) ;
3545
+ else
3546
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . SetExtensions , array . Array . Strings , array . Array . Count ) ;
3509
3547
Ensure . ZeroResult ( res ) ;
3510
3548
}
3511
3549
}
@@ -3516,7 +3554,11 @@ public static string[] git_libgit2_opts_get_extensions()
3516
3554
3517
3555
try
3518
3556
{
3519
- var res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetExtensions , out array . Array ) ;
3557
+ int res ;
3558
+ if ( isOSXArm64 )
3559
+ res = NativeMethods . git_libgit2_opts_osxarm64 ( ( int ) LibGit2Option . GetExtensions , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , IntPtr . Zero , out array . Array ) ;
3560
+ else
3561
+ res = NativeMethods . git_libgit2_opts ( ( int ) LibGit2Option . GetExtensions , out array . Array ) ;
3520
3562
Ensure . ZeroResult ( res ) ;
3521
3563
3522
3564
return array . ReadStrings ( ) ;
0 commit comments