Skip to content

Update libgit2 natives to 1.0.160 #1349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LibGit2Sharp/Commands/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public static void Fetch(Repository repository, string remote, IEnumerable<strin
fetchOptions.Prune = FetchPruneStrategy.FromConfigurationOrDefault;
}

fetchOptions.ProxyOptions = new GitProxyOptions { Version = 1 };

Proxy.git_remote_fetch(remoteHandle, refspecs, fetchOptions, logMessage);
}

Expand Down
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/GitDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ internal unsafe struct git_diff_file
public Int64 Size;
public GitDiffFlags Flags;
public UInt16 Mode;
public UInt16 IdAbbrev;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/GitErrorCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ internal enum GitErrorCategory
Describe,
Rebase,
Filesystem,
Patch
}
}
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/GitFetchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal class GitFetchOptions
public FetchPruneStrategy Prune;
public bool UpdateFetchHead = true;
public TagFetchMode download_tags;
public GitProxyOptions ProxyOptions;
public GitStrArrayManaged custom_headers;
}
}
23 changes: 23 additions & 0 deletions LibGit2Sharp/Core/GitProxyOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Runtime.InteropServices;

namespace LibGit2Sharp.Core
{
internal enum GitProxyType
{
None,
Auto,
Specified
}

[StructLayout(LayoutKind.Sequential)]
internal struct GitProxyOptions
{
public uint Version;
public GitProxyType Type;
public IntPtr Url;
public IntPtr CredentialsCb;
public IntPtr CertificateCheck;
public IntPtr CbPayload;
}
}
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/GitPushOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal class GitPushOptions
public int Version = 1;
public int PackbuilderDegreeOfParallelism;
public GitRemoteCallbacks RemoteCallbacks;
public GitProxyOptions ProxyOptions;
public GitStrArrayManaged CustomHeaders;
}
}
4 changes: 3 additions & 1 deletion LibGit2Sharp/Core/GitSubmoduleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace LibGit2Sharp.Core
{
[StructLayout(LayoutKind.Sequential)]
internal struct GitSubmoduleOptions
internal struct GitSubmoduleUpdateOptions
{
public uint Version;

Expand All @@ -12,5 +12,7 @@ internal struct GitSubmoduleOptions
public GitFetchOptions FetchOptions;

public CheckoutStrategy CloneCheckoutStrategy;

public int AllowFetch;
}
}
20 changes: 4 additions & 16 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ internal static extern unsafe int git_blob_create_fromworkdir(
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath relative_path);

internal delegate int source_callback(
IntPtr content,
int max_length,
IntPtr data);

[DllImport(libgit2)]
internal static extern unsafe int git_blob_create_fromstream(
out IntPtr stream,
Expand All @@ -137,14 +132,6 @@ internal static extern unsafe int git_blob_create_fromstream_commit(
ref GitOid oid,
IntPtr stream);

[DllImport(libgit2)]
internal static extern unsafe int git_blob_create_fromchunks(
ref GitOid oid,
git_repository* repositoryPtr,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath hintpath,
source_callback fileCallback,
IntPtr data);

[DllImport(libgit2)]
internal static extern unsafe int git_blob_filtered_content(
GitBuf buf,
Expand Down Expand Up @@ -1020,7 +1007,7 @@ internal static extern unsafe int git_packbuilder_insert_tree(
internal static extern unsafe int git_packbuilder_new(out git_packbuilder* packbuilder, git_repository* repo);

[DllImport(libgit2)]
internal static extern unsafe UInt32 git_packbuilder_object_count(git_packbuilder* packbuilder);
internal static extern unsafe UIntPtr git_packbuilder_object_count(git_packbuilder* packbuilder);

[DllImport(libgit2)]
internal static extern unsafe UInt32 git_packbuilder_set_threads(git_packbuilder* packbuilder, UInt32 numThreads);
Expand All @@ -1034,7 +1021,7 @@ internal static extern unsafe int git_packbuilder_write(
IntPtr payload);

[DllImport(libgit2)]
internal static extern unsafe UInt32 git_packbuilder_written(git_packbuilder* packbuilder);
internal static extern unsafe UIntPtr git_packbuilder_written(git_packbuilder* packbuilder);

[DllImport(libgit2)]
internal static extern unsafe int git_reference_create(
Expand Down Expand Up @@ -1213,6 +1200,7 @@ internal static extern unsafe int git_remote_connect(
git_remote* remote,
GitDirection direction,
ref GitRemoteCallbacks callbacks,
ref GitProxyOptions proxy_options,
ref GitStrArray custom_headers);

[DllImport(libgit2)]
Expand Down Expand Up @@ -1644,7 +1632,7 @@ internal static extern unsafe int git_submodule_resolve_url(
internal static extern unsafe int git_submodule_update(
git_submodule* sm,
[MarshalAs(UnmanagedType.Bool)] bool init,
ref GitSubmoduleOptions submoduleUpdateOptions);
ref GitSubmoduleUpdateOptions submoduleUpdateOptions);

internal delegate int submodule_callback(
IntPtr sm,
Expand Down
40 changes: 22 additions & 18 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,12 +1693,12 @@ public static unsafe void git_packbuilder_write(PackBuilderHandle packbuilder, F
Ensure.ZeroResult(res);
}

public static unsafe uint git_packbuilder_object_count(PackBuilderHandle packbuilder)
public static unsafe UIntPtr git_packbuilder_object_count(PackBuilderHandle packbuilder)
{
return NativeMethods.git_packbuilder_object_count(packbuilder);
}

public static unsafe uint git_packbuilder_written(PackBuilderHandle packbuilder)
public static unsafe UIntPtr git_packbuilder_written(PackBuilderHandle packbuilder)
{
return NativeMethods.git_packbuilder_written(packbuilder);
}
Expand Down Expand Up @@ -2149,13 +2149,13 @@ public static unsafe RemoteHandle git_remote_create_anonymous(RepositoryHandle r
return new RemoteHandle(handle, true);
}

public static unsafe void git_remote_connect(RemoteHandle remote, GitDirection direction, ref GitRemoteCallbacks remoteCallbacks)
public static unsafe void git_remote_connect(RemoteHandle remote, GitDirection direction, ref GitRemoteCallbacks remoteCallbacks, ref GitProxyOptions proxyOptions)
{
GitStrArrayManaged customHeaders = new GitStrArrayManaged();

try
{
int res = NativeMethods.git_remote_connect(remote, direction, ref remoteCallbacks, ref customHeaders.Array);
int res = NativeMethods.git_remote_connect(remote, direction, ref remoteCallbacks, ref proxyOptions, ref customHeaders.Array);
Ensure.ZeroResult(res);
}
catch (Exception)
Expand Down Expand Up @@ -2993,7 +2993,7 @@ public static unsafe void git_submodule_add_to_index(SubmoduleHandle submodule,
Ensure.ZeroResult(res);
}

public static unsafe void git_submodule_update(SubmoduleHandle submodule, bool init, ref GitSubmoduleOptions options)
public static unsafe void git_submodule_update(SubmoduleHandle submodule, bool init, ref GitSubmoduleUpdateOptions options)
{
var res = NativeMethods.git_submodule_update(submodule, init, ref options);
Ensure.ZeroResult(res);
Expand Down Expand Up @@ -3348,19 +3348,23 @@ public static BuiltInFeatures git_libgit2_features()
// C# equivalent of libgit2's git_libgit2_opt_t
private enum LibGitOption
{
GetMWindowSize, // GIT_OPT_GET_MWINDOW_SIZE
SetMWindowSize, // GIT_OPT_SET_MWINDOW_SIZE
GetMWindowMappedLimit, // GIT_OPT_GET_MWINDOW_MAPPED_LIMIT
SetMWindowMappedLimit, // GIT_OPT_SET_MWINDOW_MAPPED_LIMIT
GetSearchPath, // GIT_OPT_GET_SEARCH_PATH
SetSearchPath, // GIT_OPT_SET_SEARCH_PATH
SetCacheObjectLimit, // GIT_OPT_SET_CACHE_OBJECT_LIMIT
SetCacheMaxSize, // GIT_OPT_SET_CACHE_MAX_SIZE
EnableCaching, // GIT_OPT_ENABLE_CACHING
GetCachedMemory, // GIT_OPT_GET_CACHED_MEMORY
GetTemplatePath, // GIT_OPT_GET_TEMPLATE_PATH
SetTemplatePath, // GIT_OPT_SET_TEMPLATE_PATH
SetSslCertLocations, // GIT_OPT_SET_SSL_CERT_LOCATIONS
GetMWindowSize, // GIT_OPT_GET_MWINDOW_SIZE
SetMWindowSize, // GIT_OPT_SET_MWINDOW_SIZE
GetMWindowMappedLimit, // GIT_OPT_GET_MWINDOW_MAPPED_LIMIT
SetMWindowMappedLimit, // GIT_OPT_SET_MWINDOW_MAPPED_LIMIT
GetSearchPath, // GIT_OPT_GET_SEARCH_PATH
SetSearchPath, // GIT_OPT_SET_SEARCH_PATH
SetCacheObjectLimit, // GIT_OPT_SET_CACHE_OBJECT_LIMIT
SetCacheMaxSize, // GIT_OPT_SET_CACHE_MAX_SIZE
EnableCaching, // GIT_OPT_ENABLE_CACHING
GetCachedMemory, // GIT_OPT_GET_CACHED_MEMORY
GetTemplatePath, // GIT_OPT_GET_TEMPLATE_PATH
SetTemplatePath, // GIT_OPT_SET_TEMPLATE_PATH
SetSslCertLocations, // GIT_OPT_SET_SSL_CERT_LOCATIONS
SetUserAgent, // GIT_OPT_SET_USER_AGENT
EnableStrictObjectCreation, // GIT_OPT_ENABLE_STRICT_OBJECT_CREATION
SetSslCiphers, // GIT_OPT_SET_SSL_CIPHERS
GetUserAgent, // GIT_OPT_GET_USER_AGENT
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.157\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.157\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -77,6 +77,7 @@
<Compile Include="CompareOptions.cs" />
<Compile Include="Core\FileHistory.cs" />
<Compile Include="Core\GitFetchOptions.cs" />
<Compile Include="Core\GitProxyOptions.cs" />
<Compile Include="Core\GitPushUpdate.cs" />
<Compile Include="Core\GitSubmoduleIgnore.cs" />
<Compile Include="Core\GitWriteStream.cs" />
Expand Down Expand Up @@ -383,7 +384,7 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.157\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.157\build\LibGit2Sharp.NativeBinaries.props'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 3 additions & 1 deletion LibGit2Sharp/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ private IEnumerable<Reference> ListReferencesInternal(string url, CredentialsHan
using (RemoteHandle remoteHandle = BuildRemoteHandle(repository.Handle, url))
{
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks { version = 1 };
GitProxyOptions proxyOptions = new GitProxyOptions { Version = 1 };

if (credentialsProvider != null)
{
var callbacks = new RemoteCallbacks(credentialsProvider);
gitCallbacks = callbacks.GenerateCallbacks();
}

Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks, ref proxyOptions);
return Proxy.git_remote_ls(repository, remoteHandle);
}
}
Expand Down Expand Up @@ -469,6 +470,7 @@ public virtual void Push(Remote remote, IEnumerable<string> pushRefSpecs, PushOp
{
PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism,
RemoteCallbacks = gitCallbacks,
ProxyOptions = new GitProxyOptions { Version = 1 },
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/PackBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal int SetMaximumNumberOfThreads(int nThread)
/// </summary>
internal long ObjectsCount
{
get { return Proxy.git_packbuilder_object_count(packBuilderHandle); }
get { return (long)Proxy.git_packbuilder_object_count(packBuilderHandle); }
}

/// <summary>
Expand All @@ -116,7 +116,7 @@ internal long ObjectsCount
/// </summary>
internal long WrittenObjectsCount
{
get { return Proxy.git_packbuilder_written(packBuilderHandle); }
get { return (long)Proxy.git_packbuilder_written(packBuilderHandle); }
}

internal PackBuilderHandle Handle
Expand Down
7 changes: 5 additions & 2 deletions LibGit2Sharp/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,15 @@ public static IEnumerable<Reference> ListRemoteReferences(string url, Credential
using (RemoteHandle remoteHandle = Proxy.git_remote_create_anonymous(repositoryHandle, url))
{
var gitCallbacks = new GitRemoteCallbacks { version = 1 };
var proxyOptions = new GitProxyOptions { Version = 1 };

if (credentialsProvider != null)
{
var callbacks = new RemoteCallbacks(credentialsProvider);
gitCallbacks = callbacks.GenerateCallbacks();
}

Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks, ref proxyOptions);
return Proxy.git_remote_ls(null, remoteHandle);
}
}
Expand Down Expand Up @@ -726,12 +727,14 @@ public static string Clone(string sourceUrl, string workdirPath,
var remoteCallbacks = new RemoteCallbacks(options);
var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks();

var gitProxyOptions = new GitProxyOptions { Version = 1 };

var cloneOpts = new GitCloneOptions
{
Version = 1,
Bare = options.IsBare ? 1 : 0,
CheckoutOpts = gitCheckoutOptions,
FetchOpts = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks },
FetchOpts = new GitFetchOptions { ProxyOptions = gitProxyOptions, RemoteCallbacks = gitRemoteCallbacks },
};

string clonedRepoPath;
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/SubmoduleCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public virtual void Update(string name, SubmoduleUpdateOptions options)
var remoteCallbacks = new RemoteCallbacks(options);
var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks();

var gitSubmoduleUpdateOpts = new GitSubmoduleOptions
var gitSubmoduleUpdateOpts = new GitSubmoduleUpdateOptions
{
Version = 1,
CheckoutOptions = gitCheckoutOptions,
FetchOptions = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks },
FetchOptions = new GitFetchOptions { ProxyOptions = new GitProxyOptions { Version = 1 }, RemoteCallbacks = gitRemoteCallbacks },
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE
};

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LibGit2Sharp.NativeBinaries" version="1.0.157" targetFramework="net4" allowedVersions="[1.0.157]" />
<package id="LibGit2Sharp.NativeBinaries" version="1.0.160" targetFramework="net4" allowedVersions="[1.0.160]" />
</packages>