diff options
-rw-r--r-- | Lib/NativeBinaries/x86/git2.dll | bin | 274432 -> 278016 bytes | |||
-rw-r--r-- | Lib/NativeBinaries/x86/git2.pdb | bin | 1814528 -> 1855488 bytes | |||
-rw-r--r-- | LibGit2Sharp.Tests/Resources/testrepo.git/config | 3 | ||||
-rw-r--r-- | LibGit2Sharp/Configuration.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/Core/DatabaseSafeHandle.cs | 11 | ||||
-rw-r--r-- | LibGit2Sharp/Core/GitRepositoryPathId.cs | 10 | ||||
-rw-r--r-- | LibGit2Sharp/Core/NativeMethods.cs | 21 | ||||
-rwxr-xr-x | LibGit2Sharp/Core/ObjectSafeWrapper.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/GitObject.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/LibGit2Sharp.csproj | 2 | ||||
-rw-r--r-- | LibGit2Sharp/RemoteCollection.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/Repository.cs | 22 | ||||
-rw-r--r-- | LibGit2Sharp/RepositoryInformation.cs | 4 | ||||
m--------- | libgit2 | 0 |
14 files changed, 41 insertions, 40 deletions
diff --git a/Lib/NativeBinaries/x86/git2.dll b/Lib/NativeBinaries/x86/git2.dll Binary files differindex dab0d043..8de18ab4 100644 --- a/Lib/NativeBinaries/x86/git2.dll +++ b/Lib/NativeBinaries/x86/git2.dll diff --git a/Lib/NativeBinaries/x86/git2.pdb b/Lib/NativeBinaries/x86/git2.pdb Binary files differindex e45294c2..1ff189bf 100644 --- a/Lib/NativeBinaries/x86/git2.pdb +++ b/Lib/NativeBinaries/x86/git2.pdb diff --git a/LibGit2Sharp.Tests/Resources/testrepo.git/config b/LibGit2Sharp.Tests/Resources/testrepo.git/config index e69de29b..8e7c7b42 100644 --- a/LibGit2Sharp.Tests/Resources/testrepo.git/config +++ b/LibGit2Sharp.Tests/Resources/testrepo.git/config @@ -0,0 +1,3 @@ +[core] + repositoryformatversion = 0 + bare = true diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index 83cc9d65..9ab0b60b 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -302,7 +302,7 @@ namespace LibGit2Sharp { 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) diff --git a/LibGit2Sharp/Core/DatabaseSafeHandle.cs b/LibGit2Sharp/Core/DatabaseSafeHandle.cs new file mode 100644 index 00000000..2761be5f --- /dev/null +++ b/LibGit2Sharp/Core/DatabaseSafeHandle.cs @@ -0,0 +1,11 @@ +namespace LibGit2Sharp.Core +{ + internal class DatabaseSafeHandle : SafeHandleBase + { + protected override bool ReleaseHandle() + { + NativeMethods.git_odb_free(handle); + return true; + } + } +} diff --git a/LibGit2Sharp/Core/GitRepositoryPathId.cs b/LibGit2Sharp/Core/GitRepositoryPathId.cs deleted file mode 100644 index 3fb3d618..00000000 --- a/LibGit2Sharp/Core/GitRepositoryPathId.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace LibGit2Sharp.Core -{ - internal enum GitRepositoryPathId - { - GIT_REPO_PATH, - GIT_REPO_PATH_INDEX, - GIT_REPO_PATH_ODB, - GIT_REPO_PATH_WORKDIR - } -} diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 56b9cc24..62d02500 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -165,7 +165,7 @@ namespace LibGit2Sharp.Core 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); @@ -181,10 +181,10 @@ namespace LibGit2Sharp.Core [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); @@ -250,9 +250,9 @@ namespace LibGit2Sharp.Core 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)] @@ -264,12 +264,10 @@ namespace LibGit2Sharp.Core [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( @@ -307,7 +305,10 @@ namespace LibGit2Sharp.Core [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); diff --git a/LibGit2Sharp/Core/ObjectSafeWrapper.cs b/LibGit2Sharp/Core/ObjectSafeWrapper.cs index 1564dd5e..04241b5d 100755 --- a/LibGit2Sharp/Core/ObjectSafeWrapper.cs +++ b/LibGit2Sharp/Core/ObjectSafeWrapper.cs @@ -36,7 +36,7 @@ namespace LibGit2Sharp.Core return; } - NativeMethods.git_object_close(objectPtr); + NativeMethods.git_object_free(objectPtr); objectPtr = IntPtr.Zero; } diff --git a/LibGit2Sharp/GitObject.cs b/LibGit2Sharp/GitObject.cs index c8cb1fa4..8137011f 100644 --- a/LibGit2Sharp/GitObject.cs +++ b/LibGit2Sharp/GitObject.cs @@ -66,7 +66,7 @@ namespace LibGit2Sharp } finally { - NativeMethods.git_object_close(obj); + NativeMethods.git_object_free(obj); } } diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 346cad8d..00b193d8 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -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" /> @@ -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" /> diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index 66f78e98..dcb582b8 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -21,7 +21,7 @@ namespace LibGit2Sharp 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) { diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 99159a26..a3034f49 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -177,9 +177,14 @@ namespace LibGit2Sharp { 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> @@ -196,20 +201,11 @@ namespace LibGit2Sharp 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; } diff --git a/LibGit2Sharp/RepositoryInformation.cs b/LibGit2Sharp/RepositoryInformation.cs index 8d27f447..9453c754 100644 --- a/LibGit2Sharp/RepositoryInformation.cs +++ b/LibGit2Sharp/RepositoryInformation.cs @@ -14,8 +14,8 @@ namespace LibGit2Sharp 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); diff --git a/libgit2 b/libgit2 -Subproject e4c93a392763a006d11e1c1dd01c12f85498dad +Subproject be00b00dd1468f1c625ca3fadc61f2a16edfb8d |