Skip to content

Commit

Permalink
Upgrade libgit2 binaries to be00b00
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltoken committed Dec 20, 2011
1 parent b508bbd commit 2a0f4bf
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 41 deletions.
Binary file modified Lib/NativeBinaries/x86/git2.dll
Binary file not shown.
Binary file modified Lib/NativeBinaries/x86/git2.pdb
Binary file not shown.
3 changes: 3 additions & 0 deletions LibGit2Sharp.Tests/Resources/testrepo.git/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[core]
repositoryformatversion = 0
bare = true
2 changes: 1 addition & 1 deletion LibGit2Sharp/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void Init()
{
if (repository != null)
{
Ensure.Success(NativeMethods.git_repository_config(out localHandle, repository.Handle, globalConfigPath, systemConfigPath));
Ensure.Success(NativeMethods.git_repository_config(out localHandle, repository.Handle));
}

if (globalConfigPath != null)
Expand Down
11 changes: 11 additions & 0 deletions LibGit2Sharp/Core/DatabaseSafeHandle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace LibGit2Sharp.Core
{
internal class DatabaseSafeHandle : SafeHandleBase
{
protected override bool ReleaseHandle()
{
NativeMethods.git_odb_free(handle);
return true;
}
}
}
10 changes: 0 additions & 10 deletions LibGit2Sharp/Core/GitRepositoryPathId.cs

This file was deleted.

21 changes: 11 additions & 10 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static extern int git_index_find(
public static extern IntPtr git_lasterror();

[DllImport(libgit2)]
public static extern void git_object_close(IntPtr obj);
public static extern void git_object_free(IntPtr obj);

[DllImport(libgit2)]
public static extern IntPtr git_object_id(IntPtr obj);
Expand All @@ -181,10 +181,10 @@ public static extern int git_index_find(

[DllImport(libgit2)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool git_odb_exists(IntPtr db, ref GitOid id);
public static extern bool git_odb_exists(DatabaseSafeHandle db, ref GitOid id);

[DllImport(libgit2)]
public static extern void git_odb_object_close(IntPtr obj);
public static extern void git_odb_free(IntPtr obj);

[DllImport(libgit2)]
public static extern int git_oid_cmp(ref GitOid a, ref GitOid b);
Expand Down Expand Up @@ -250,9 +250,9 @@ public static extern int git_reference_set_target(
public static extern void git_remote_free(IntPtr remote);

[DllImport(libgit2)]
public static extern int git_remote_get(
public static extern int git_remote_load(
out RemoteSafeHandle remote,
ConfigurationSafeHandle cfg,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name);

[DllImport(libgit2)]
Expand All @@ -264,12 +264,10 @@ public static extern int git_remote_get(
[DllImport(libgit2)]
public static extern int git_repository_config(
out ConfigurationSafeHandle cfg,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string userConfigPath,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string systemConfigPath);
RepositorySafeHandle repo);

[DllImport(libgit2)]
public static extern IntPtr git_repository_database(RepositorySafeHandle repository);
public static extern int git_repository_odb(out DatabaseSafeHandle odb, RepositorySafeHandle repository);

[DllImport(libgit2)]
public static extern int git_repository_discover(
Expand Down Expand Up @@ -307,7 +305,10 @@ public static extern int git_repository_open(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string path);

[DllImport(libgit2)]
public static extern IntPtr git_repository_path(RepositorySafeHandle repository, GitRepositoryPathId pathIdentifier);
public static extern IntPtr git_repository_path(RepositorySafeHandle repository);

[DllImport(libgit2)]
public static extern IntPtr git_repository_workdir(RepositorySafeHandle repository);

[DllImport(libgit2)]
public static extern void git_revwalk_free(IntPtr walker);
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/ObjectSafeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void Dispose(bool disposing)
return;
}

NativeMethods.git_object_close(objectPtr);
NativeMethods.git_object_free(objectPtr);
objectPtr = IntPtr.Zero;
}

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/GitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static GitObject CreateFromPtr(IntPtr obj, ObjectId id, Repository repo
}
finally
{
NativeMethods.git_object_close(obj);
NativeMethods.git_object_free(obj);
}
}

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="Configuration.cs" />
<Compile Include="ConfigurationLevel.cs" />
<Compile Include="Core\Compat\Tuple.cs" />
<Compile Include="Core\DatabaseSafeHandle.cs" />
<Compile Include="Core\EnumExtensions.cs" />
<Compile Include="DetachedHead.cs" />
<Compile Include="LibGit2Exception.cs" />
Expand All @@ -63,7 +64,6 @@
<Compile Include="Core\GitObjectTypeMap.cs" />
<Compile Include="Core\GitOid.cs" />
<Compile Include="Core\GitReferenceType.cs" />
<Compile Include="Core\GitRepositoryPathId.cs" />
<Compile Include="Core\GitSignature.cs" />
<Compile Include="FileStatus.cs" />
<Compile Include="Core\GitTime.cs" />
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/RemoteCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private Remote RemoteForName(string name)
var remote = new Remote();
RemoteSafeHandle handle;

int res = NativeMethods.git_remote_get(out handle, repository.Config.LocalHandle, name);
int res = NativeMethods.git_remote_load(out handle, repository.Handle, name);

if (res == (int)GitErrorCode.GIT_ENOTFOUND)
{
Expand Down
22 changes: 9 additions & 13 deletions LibGit2Sharp/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,14 @@ public bool HasObject(string sha) //TODO: To be removed from front facing API (m
{
var id = new ObjectId(sha);

IntPtr odb = NativeMethods.git_repository_database(handle);
GitOid oid = id.Oid;
return NativeMethods.git_odb_exists(odb, ref oid);
DatabaseSafeHandle odb;
Ensure.Success(NativeMethods.git_repository_odb(out odb, handle));

using(odb)
{
GitOid oid = id.Oid;
return NativeMethods.git_odb_exists(odb, ref oid);
}
}

/// <summary>
Expand All @@ -196,20 +201,11 @@ public static string Init(string path, bool isBare = false)
int res = NativeMethods.git_repository_init(out repo, PosixPathHelper.ToPosix(path), isBare);
Ensure.Success(res);

string normalizedPath = NativeMethods.git_repository_path(repo, GitRepositoryPathId.GIT_REPO_PATH).MarshallAsString();
string normalizedPath = NativeMethods.git_repository_path(repo).MarshallAsString();
repo.SafeDispose();

string nativePath = PosixPathHelper.ToNative(normalizedPath);

// TODO: To be removed once it's being dealt with by libgit2
// libgit2 doesn't currently create the git config file, so create a minimal one if we can't find it
// See https://github.com/libgit2/libgit2sharp/issues/56 for details
string configFile = Path.Combine(nativePath, "config");
if (!File.Exists(configFile))
{
File.WriteAllText(configFile, "[core]\n\trepositoryformatversion = 0\n");
}

return nativePath;
}

Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/RepositoryInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ internal RepositoryInformation(Repository repo, bool isBare)
this.repo = repo;
IsBare = isBare;

string posixPath = NativeMethods.git_repository_path(repo.Handle, GitRepositoryPathId.GIT_REPO_PATH).MarshallAsString();
string posixWorkingDirectoryPath = NativeMethods.git_repository_path(repo.Handle, GitRepositoryPathId.GIT_REPO_PATH_WORKDIR).MarshallAsString();
string posixPath = NativeMethods.git_repository_path(repo.Handle).MarshallAsString();
string posixWorkingDirectoryPath = NativeMethods.git_repository_workdir(repo.Handle).MarshallAsString();

Path = PosixPathHelper.ToNative(posixPath);
WorkingDirectory = PosixPathHelper.ToNative(posixWorkingDirectoryPath);
Expand Down
2 changes: 1 addition & 1 deletion libgit2
Submodule libgit2 updated 115 files

0 comments on commit 2a0f4bf

Please sign in to comment.