8000 Upgrade libgit2 binaries to 7a361e9 · gitextensions/libgit2sharp@6aac12a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6aac12a

Browse files
committed
Upgrade libgit2 binaries to 7a361e9
Include native amd64 binaries. Fix libgit2#55 and libgit2#70
1 parent 8344599 commit 6aac12a

17 files changed

+38
-82
lines changed

Lib/NativeBinaries/amd64/dummy.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

Lib/NativeBinaries/amd64/git2.dll

530 KB
Binary file not shown.

Lib/NativeBinaries/amd64/git2.pdb

2.35 MB
Binary file not shown.

Lib/NativeBinaries/x86/git2.dll

512 Bytes
Binary file not shown.

Lib/NativeBinaries/x86/git2.pdb

8 KB
Binary file not shown.

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
2222
<ErrorReport>prompt</ErrorReport>
2323
<WarningLevel>4</WarningLevel>
24-
<PlatformTarget>x86</PlatformTarget>
2524
<DocumentationFile />
2625
</PropertyGroup>
2726
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -31,7 +30,6 @@
3130
<DefineConstants>TRACE</DefineConstants>
3231
<ErrorReport>prompt</ErrorReport>
3332
<WarningLevel>4</WarningLevel>
34-
<PlatformTarget>x86</PlatformTarget>
3533
<DocumentationFile />
3634
</PropertyGroup>
3735
<ItemGroup>

LibGit2Sharp/Configuration.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,19 @@ public bool HasSystemConfig
6262
get { return systemConfigPath != null; }
6363
}
6464

65-
private static string ConvertPath(Func<byte[], int> pathRetriever)
65+
private static string ConvertPath(Func<byte[], IntPtr, int> pathRetriever)
6666
{
6767
var buffer = new byte[NativeMethods.GIT_PATH_MAX];
6868

69-
int result = pathRetriever(buffer);
69+
int result = pathRetriever(buffer, new IntPtr(NativeMethods.GIT_PATH_MAX));
7070

71-
//TODO: Make libgit2 return different codes to clearly identify a not found file (GIT_ENOTFOUND ) from any other error (!= GIT_SUCCESS)
72-
if (result != (int)GitErrorCode.GIT_SUCCESS)
71+
if (result == (int)GitErrorCode.GIT_ENOTFOUND)
7372
{
7473
return null;
7574
}
7675

76+
Ensure.Success(result);
77+
7778
return Utf8Marshaler.Utf8FromBuffer(buffer);
7879
}
7980

@@ -137,28 +138,28 @@ private static Dictionary<Type, Func<string, object, ConfigurationSafeHandle, ob
137138
dic.Add(typeof(int), (key, dv, handle) =>
138139
{
139140
int value;
140-
int res = NativeMethods.git_config_get_int32(handle, key, out value);
141+
int res = NativeMethods.git_config_get_int32(out value, handle, key);
141142
return ProcessReadResult<object>(res, value, dv);
142143
});
143144

144145
dic.Add(typeof(long), (key, dv, handle) =>
145146
{
146147
long value;
147-
int res = NativeMethods.git_config_get_int64(handle, key, out value);
148+
int res = NativeMethods.git_config_get_int64(out value, handle, key);
148149
return ProcessReadResult<object>(res, value, dv);
149150
});
150151

151152
dic.Add(typeof(bool), (key, dv, handle) =>
152153
{
153154
bool value;
154-
int res = NativeMethods.git_config_get_bool(handle, key, out value);
155+
int res = NativeMethods.git_config_get_bool(out value, handle, key);
155156
return ProcessReadResult<object>(res, value, dv);
156157
});
157158

158159
dic.Add(typeof(string), (key, dv, handle) =>
159160
{
160161
string value;
161-
int res = NativeMethods.git_config_get_string(handle, key, out value);
162+
int res = NativeMethods.git_config_get_string(out value, handle, key);
162163
return ProcessReadResult<object>(res, value, dv);
163164
});
164165

LibGit2Sharp/Core/Ensure.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public static void ArgumentNotNullOrEmptyString(string argumentValue, string arg
5454
/// True when positive values are allowed as well.</param>
5555
public static void Success(int result, bool allowPositiveResult = false)
5656
{
57-
if (result == (int)GitErrorCode.GIT_SUCCESS)
57+
if (result == (int)GitErrorCode.GIT_OK)
5858
{
5959
return;
6060
}
6161

62-
if (allowPositiveResult && result > (int)GitErrorCode.GIT_SUCCESS)
62+
if (allowPositiveResult && result > (int)GitErrorCode.GIT_OK)
6363
{
6464
return;
6565
}
@@ -70,7 +70,7 @@ public static void Success(int result, bool allowPositiveResult = false)
7070

7171
throw new LibGit2Exception(
7272
String.Format(CultureInfo.InvariantCulture, "An error was raised by libgit2. Class = {0} ({1}).{2}{3}",
73-
Enum.GetName(typeof(GitErrorClass), error.Klass.ToInt32()),
73+
Enum.GetName(typeof(GitErrorType), error.Klass.ToInt32()),
7474
result,
7575
Environment.NewLine,
7676
errorMessage));

LibGit2Sharp/Core/GitError.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class GitError
1010
public IntPtr Klass;
1111
}
1212

13-
internal enum GitErrorClass
13+
internal enum GitErrorType
1414
{
1515
GITERR_NOMEMORY,
1616
GITERR_OS,
@@ -26,5 +26,6 @@ internal enum GitErrorClass
2626
GITERR_NET,
2727
GITERR_TAG,
2828
GITERR_TREE,
29+
GITERR_INDEXER,
2930
}
3031
}

LibGit2Sharp/Core/GitErrorCode.cs

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,13 @@
22
{
33
internal enum GitErrorCode
44
{
5-
/// <summary>
6-
/// Operation completed successfully.
7-
/// </summary>
8-
GIT_SUCCESS = 0,
9-
10-
/// <summary>
11-
/// Operation failed, with unspecified reason.
12-
/// This value also serves as the base error code; all other
13-
/// error codes are subtracted from it such that all errors
14-
/// are &lt; 0, in typical POSIX C tradition.
15-
/// </summary>
5+
GIT_OK = 0,
166
GIT_ERROR = -1,
17-
18-
/// <summary>
19-
/// Input does not exist in the scope searched.
20-
/// </summary>
217
GIT_ENOTFOUND = -3,
22-
23-
/// <summary>
24-
/// A reference with this name already exists
25-
/// </summary>
26-
GIT_EEXISTS = -23,
27-
28-
/// <summary>
29-
/// The given integer literal is too large to be parsed
30-
/// </summary>
31-
GIT_EOVERFLOW = -24,
32-
33-
/// <summary>
34-
/// The given short oid is ambiguous
35-
/// </summary>
36-
GIT_EAMBIGUOUS = -29,
37-
38-
/// <summary>
39-
/// Skip and passthrough the given ODB backend
40-
/// </summary>
8+
GIT_EEXISTS = -4,
9+
GIT_EAMBIGUOUS = -5,
10+
GIT_EBUFS = -6,
4111
GIT_EPASSTHROUGH = -30,
42-
43-
/// <summary>
44-
/// The buffer is too short to satisfy the request
45-
/// </summary>
46-
GIT_ESHORTBUFFER = -32,
47-
48-
/// <summary>
49-
/// The revision walker is empty; there are no more commits left to iterate
50-
/// </summary>
51-
GIT_EREVWALKOVER = -33,
12+
GIT_EREVWALKOVER = -31,
5213
}
5314
}

LibGit2Sharp/Core/Libgit2UnsafeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal static unsafe class Libgit2UnsafeHelper
1111
public static IList<string> ListAllReferenceNames(RepositorySafeHandle repo, GitReferenceType types)
1212
{
1313
UnSafeNativeMethods.git_strarray strArray;
14-
int res = UnSafeNativeMethods.git_reference_listall(out strArray, repo, types);
14+
int res = UnSafeNativeMethods.git_reference_list(out strArray, repo, types);
1515
Ensure.Success(res);
1616

1717
return BuildListOf(strArray);

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ public static string ProcessorArchitecture
4040
{
4141
get
4242
{
43-
//TODO: When amd64 version of libgit2.dll is available, uncomment the following lines
44-
//if (Compat.Environment.Is64BitProcess)
45-
//{
46-
// return "amd64";
47-
//}
43+
if (Compat.Environment.Is64BitProcess)
44+
{
45+
return "amd64";
46+
}
4847

4948
return "x86";
5049
}
@@ -144,38 +143,37 @@ public static extern int git_commit_create(
144143
public static extern int git_config_delete(ConfigurationSafeHandle cfg, string name);
145144

146145
[DllImport(libgit2)]
147-
public static extern int git_config_find_global(byte[] global_config_path);
146+
public static extern int git_config_find_global(byte[] global_config_path, IntPtr length);
148147

149148
[DllImport(libgit2)]
150-
public static extern int git_config_find_system(byte[] system_config_path);
149+
public static extern int git_config_find_system(byte[] system_config_path, IntPtr length);
151150

152151
[DllImport(libgit2)]
153152
public static extern void git_config_free(IntPtr cfg);
154153

155154
[DllImport(libgit2)]
156155
public static extern int git_config_get_bool(
156+
[MarshalAs(UnmanagedType.Bool)] out bool value,
157157
ConfigurationSafeHandle cfg,
158-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
159-
[MarshalAs(UnmanagedType.Bool)]
160-
out bool value);
158+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name);
161159

162160
[DllImport(libgit2)]
163161
public static extern int git_config_get_int32(
162+
out int value,
164163
ConfigurationSafeHandle cfg,
165-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
166-
out int value);
164+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name);
167165

168166
[DllImport(libgit2)]
169167
public static extern int git_config_get_int64(
168+
out long value,
170169
ConfigurationSafeHandle cfg,
171-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
172-
out long value);
170+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name);
173171

174172
[DllImport(libgit2)]
175173
public static extern int git_config_get_string(
174+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] out string value,
176175
ConfigurationSafeHandle cfg,
177-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
178-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] out string value);
176+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name);
179177

180178
[DllImport(libgit2)]
181179
public static extern int git_config_open_global(out ConfigurationSafeHandle cfg);

LibGit2Sharp/Core/UnSafeNativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static unsafe class UnSafeNativeMethods
99
private const string libgit2 = "git2";
1010

1111
[DllImport(libgit2)]
12-
public static extern int git_reference_listall(out git_strarray array, RepositorySafeHandle repo, GitReferenceType flags);
12+
public static extern int git_reference_list(out git_strarray array, RepositorySafeHandle repo, GitReferenceType flags);
1313

1414
[DllImport(libgit2)]
1515
public static extern int git_remote_list(out git_strarray array, RepositorySafeHandle repo);

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<WarningLevel>4</WarningLevel>
2525
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
2626
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
27-
<PlatformTarget>x86</PlatformTarget>
2827
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
2928
</PropertyGroup>
3029
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -36,7 +35,6 @@
3635
<WarningLevel>4</WarningLevel>
3736
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3837
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
39-
<PlatformTarget>x86</PlatformTarget>
4038
<DocumentationFile>bin\Release\LibGit2Sharp.xml</DocumentationFile>
4139
</PropertyGroup>
4240
<ItemGroup>

LibGit2Sharp/ObjectDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public bool Contains(ObjectId objectId)
3333
{
3434
var oid = objectId.Oid;
3535

36-
return NativeMethods.git_odb_exists(handle, ref oid) != (int)GitErrorCode.GIT_SUCCESS;
36+
return NativeMethods.git_odb_exists(handle, ref oid) != (int)GitErrorCode.GIT_OK;
3737
}
3838

3939
/// <summary>

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
54695f4098c75801f477f5bc229a52653484e08a
1+
7a361e93f39789e9523caeb3ef8754173165aab7

libgit2

Submodule libgit2 updated 131 files

0 commit comments

Comments
 (0)
0