Skip to content

Commit 63771c5

Browse files
committed
Merge pull request #1298 from ethomson/libgit2_update
Update libgit2
2 parents db442ba + 2242a9b commit 63771c5

15 files changed

+99
-39
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
### Changes
1818

19+
- The native libraries are now expected to be in the `lib` directory,
20+
instead of `NativeBinaries` for improved mono compatibility. In
21+
addition, the names of platform architectures now better reflect
22+
the vendor naming (eg, `x86_64` instead of `amd64` on Linux).
1923
- Obsolete the config paths in RepositoryOptions
2024

2125
### Fixes

CI/build.msbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
DestinationFiles="@(OutputFiles->'$(DeployFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
5050

5151
<ItemGroup>
52-
<NativeBinaries Include="$(TestBuildDir)\NativeBinaries\**\*.*" />
52+
<NativeBinaries Include="$(TestBuildDir)\lib\**\*.*" />
5353
</ItemGroup>
5454

5555
<Copy SourceFiles="@(NativeBinaries)"
56-
DestinationFiles="@(NativeBinaries->'$(DeployFolder)\NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
56+
DestinationFiles="@(NativeBinaries->'$(DeployFolder)\lib\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
5757
</Target>
5858
</Project>

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void CanGetMinimumCompiledInFeatures()
1919
public void CanRetrieveValidVersionString()
2020
{
2121
// Version string format is:
22-
// Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)
22+
// Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|x64 - features)
2323
// Example output:
2424
// "0.17.0[-pre20170914123547]-deadcafe-06d772d (x86 - Threads, Https)"
2525

@@ -29,7 +29,7 @@ public void CanRetrieveValidVersionString()
2929
// version: '0.17.0[-pre20170914123547]' LibGit2Sharp version number.
3030
// git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash.
3131
// git2hash: '06d772d' LibGit2 library hash.
32-
// arch: 'x86' or 'amd64' LibGit2 target.
32+
// arch: 'x86' or 'x64' LibGit2 target.
3333
// git2Features: 'Threads, Ssh' LibGit2 features compiled with.
3434
string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3}(-(pre|dev)\d{14})?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
3535

@@ -38,7 +38,7 @@ public void CanRetrieveValidVersionString()
3838
Match regexResult = Regex.Match(versionInfo, regex);
3939

4040
Assert.True(regexResult.Success, "The following version string format is enforced:" +
41-
"Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)");
41+
"Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|x64 - features)");
4242

4343
GroupCollection matchGroups = regexResult.Groups;
4444

LibGit2Sharp.Tests/ShadowCopyFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ public void CanProbeForNativeBinariesFromAShadowCopiedAssembly()
5959

6060
if (!Constants.IsRunningOnUnix)
6161
{
62-
// ...that this cache doesn't contain the `NativeBinaries` folder
62+
// ...that this cache doesn't contain the `lib` folder
6363
string cachedAssemblyParentPath = Path.GetDirectoryName(cachedAssemblyLocation);
64-
Assert.False(Directory.Exists(Path.Combine(cachedAssemblyParentPath, "NativeBinaries")));
64+
Assert.False(Directory.Exists(Path.Combine(cachedAssemblyParentPath, "lib")));
6565

66-
// ...whereas `NativeBinaries` of course exists next to the source assembly
66+
// ...whereas `lib` of course exists next to the source assembly
6767
string sourceAssemblyParentPath =
6868
Path.GetDirectoryName(new Uri(sourceAssembly.EscapedCodeBase).LocalPath);
69-
Assert.True(Directory.Exists(Path.Combine(sourceAssemblyParentPath, "NativeBinaries")));
69+
Assert.True(Directory.Exists(Path.Combine(sourceAssemblyParentPath, "lib")));
7070
}
7171

7272
AppDomain.Unload(domain);

LibGit2Sharp/Core/GitMergeOpts.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ internal struct GitMergeOpts
3535
/// </summary>
3636
public uint RecursionLimit;
3737

38+
/// <summary>
39+
/// Default merge driver to be used when both sides of a merge have
40+
/// changed. The default is the `text` driver.
41+
/// </summary>
42+
public string DefaultDriver;
43+
3844
/// <summary>
3945
/// Flags for automerging content.
4046
/// </summary>

LibGit2Sharp/Core/GitWriteStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace LibGit2Sharp.Core
55
{
66
[StructLayout(LayoutKind.Sequential)]
7-
internal class GitWriteStream
7+
internal struct GitWriteStream
88
{
99
[MarshalAs(UnmanagedType.FunctionPtr)]
1010
public write_fn write;

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ internal delegate int source_callback(
126126
int max_length,
127127
IntPtr data);
128128

129+
[DllImport(libgit2)]
130+
internal static extern unsafe int git_blob_create_fromstream(
131+
out IntPtr stream,
132+
git_repository* repositoryPtr,
133+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath hintpath);
134+
135+
[DllImport(libgit2)]
136+
internal static extern unsafe int git_blob_create_fromstream_commit(
137+
ref GitOid oid,
138+
IntPtr stream);
139+
129140
[DllImport(libgit2)]
130141
internal static extern unsafe int git_blob_create_fromchunks(
131142
ref GitOid oid,

LibGit2Sharp/Core/Platform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static class Platform
1313
{
1414
public static string ProcessorArchitecture
1515
{
16-
get { return Environment.Is64BitProcess ? "amd64" : "x86"; }
16+
get { return Environment.Is64BitProcess ? "x64" : "x86"; }
1717
}
1818

1919
public static OperatingSystemType OperatingSystem

LibGit2Sharp/Core/Proxy.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ public static unsafe BlameHandle git_blame_file(
115115

116116
#region git_blob_
117117

118-
public static unsafe ObjectId git_blob_create_fromchunks(RepositoryHandle repo, FilePath hintpath, NativeMethods.source_callback fileCallback)
118+
public static unsafe IntPtr git_blob_create_fromstream(RepositoryHandle repo, FilePath hintpath)
119119
{
120-
var oid = new GitOid();
121-
int res = NativeMethods.git_blob_create_fromchunks(ref oid, repo, hintpath, fileCallback, IntPtr.Zero);
122-
123-
if (res == (int)GitErrorCode.User)
124-
{
125-
throw new EndOfStreamException("The stream ended unexpectedly");
126-
}
120+
IntPtr writestream_ptr;
127121

128-
Ensure.ZeroResult(res);
122+
Ensure.ZeroResult(NativeMethods.git_blob_create_fromstream(out writestream_ptr, repo, hintpath));
123+
return writestream_ptr;
124+
}
129125

126+
public static unsafe ObjectId git_blob_create_fromstream_commit(IntPtr writestream_ptr)
127+
{
128+
var oid = new GitOid();
129+
Ensure.ZeroResult(NativeMethods.git_blob_create_fromstream_commit(ref oid, writestream_ptr));
130130
return oid;
131131
}
132132

LibGit2Sharp/Filter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ int StreamCreateCallback(out IntPtr git_writestream_out, GitFilter self, IntPtr
261261
Marshal.StructureToPtr(state.thisStream, state.thisPtr, false);
262262

263263
state.nextPtr = git_writestream_next;
264-
state.nextStream = new GitWriteStream();
265-
Marshal.PtrToStructure(state.nextPtr, state.nextStream);
264+
state.nextStream = (GitWriteStream)Marshal.PtrToStructure(state.nextPtr, typeof(GitWriteStream));
266265

267266
state.filterSource = FilterSource.FromNativePtr(filterSourcePtr);
268267
state.output = new WriteStream(state.nextStream, state.nextPtr);

0 commit comments

Comments
 (0)