@@ -14,6 +14,9 @@ namespace LibGit2Sharp.Core
1414{
1515 internal class Proxy
1616 {
17+ internal static readonly bool isOSXArm64 = RuntimeInformation . ProcessArchitecture == Architecture . Arm64
18+ && RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
19+
1720 #region git_blame_
1821
1922 public static unsafe BlameHandle git_blame_file (
@@ -3408,7 +3411,11 @@ public static string git_libgit2_opts_get_search_path(ConfigurationLevel level)
34083411
34093412 using ( var buf = new GitBuf ( ) )
34103413 {
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 ) ;
34123419 Ensure . ZeroResult ( res ) ;
34133420
34143421 path = LaxUtf8Marshaler . FromNative ( buf . ptr ) ?? string . Empty ;
@@ -3419,7 +3426,10 @@ public static string git_libgit2_opts_get_search_path(ConfigurationLevel level)
34193426
34203427 public static void git_libgit2_opts_enable_strict_hash_verification ( bool enabled )
34213428 {
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 ) ;
34233433 }
34243434
34253435 /// <summary>
@@ -3432,7 +3442,11 @@ public static void git_libgit2_opts_enable_strict_hash_verification(bool enabled
34323442 /// </param>
34333443 public static void git_libgit2_opts_set_search_path ( ConfigurationLevel level , string path )
34343444 {
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 ) ;
34363450 Ensure . ZeroResult ( res ) ;
34373451 }
34383452
@@ -3443,7 +3457,11 @@ public static void git_libgit2_opts_set_search_path(ConfigurationLevel level, st
34433457 public static void git_libgit2_opts_set_enable_caching ( bool enabled )
34443458 {
34453459 // 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 ) ;
34473465 Ensure . ZeroResult ( res ) ;
34483466 }
34493467
@@ -3454,7 +3472,11 @@ public static void git_libgit2_opts_set_enable_caching(bool enabled)
34543472 public static void git_libgit2_opts_set_enable_ofsdelta ( bool enabled )
34553473 {
34563474 // 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 ) ;
34583480 Ensure . ZeroResult ( res ) ;
34593481 }
34603482
@@ -3465,7 +3487,11 @@ public static void git_libgit2_opts_set_enable_ofsdelta(bool enabled)
34653487 public static void git_libgit2_opts_set_enable_strictobjectcreation ( bool enabled )
34663488 {
34673489 // 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 ) ;
34693495 Ensure . ZeroResult ( res ) ;
34703496 }
34713497
@@ -3476,7 +3502,11 @@ public static void git_libgit2_opts_set_enable_strictobjectcreation(bool enabled
34763502 /// <param name="userAgent">The user-agent string to use</param>
34773503 public static void git_libgit2_opts_set_user_agent ( string userAgent )
34783504 {
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 ) ;
34803510 Ensure . ZeroResult ( res ) ;
34813511 }
34823512
@@ -3492,7 +3522,11 @@ public static string git_libgit2_opts_get_user_agent()
34923522
34933523 using ( var buf = new GitBuf ( ) )
34943524 {
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 ) ;
34963530 Ensure . ZeroResult ( res ) ;
34973531
34983532 userAgent = LaxUtf8Marshaler . FromNative ( buf . ptr ) ?? string . Empty ;
@@ -3505,7 +3539,11 @@ public static void git_libgit2_opts_set_extensions(string[] extensions)
35053539 {
35063540 using ( var array = GitStrArrayManaged . BuildFrom ( extensions ) )
35073541 {
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 ) ;
35093547 Ensure . ZeroResult ( res ) ;
35103548 }
35113549 }
@@ -3516,7 +3554,11 @@ public static string[] git_libgit2_opts_get_extensions()
35163554
35173555 try
35183556 {
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 ) ;
35203562 Ensure . ZeroResult ( res ) ;
35213563
35223564 return array . ReadStrings ( ) ;
0 commit comments