Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Nov 26, 2024
1 parent bd5fb50 commit 11aae8b
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 194 deletions.
3 changes: 1 addition & 2 deletions LibGit2Sharp/Core/GitFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp.Core
{
Expand Down Expand Up @@ -119,7 +118,7 @@ public delegate int git_filter_stream_fn(
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct git_filter_source
{
public RepositoryHandle repository;
public IntPtr repository;

public char* path;

Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/Core/Handles/Libgit2Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ internal unsafe abstract class Libgit2Object : SafeHandle
private readonly Guid id;
#endif

internal unsafe Libgit2Object(void* ptr, bool owned)
: this(new IntPtr(ptr), owned)
internal unsafe Libgit2Object()
: base(IntPtr.Zero, true)
{
}

Expand Down
125 changes: 125 additions & 0 deletions LibGit2Sharp/Core/Handles/Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace LibGit2Sharp.Core.Handles

internal unsafe class TreeEntryHandle : Libgit2Object
{
internal TreeEntryHandle()
: base()
{
}

internal TreeEntryHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -21,6 +26,11 @@ protected override bool ReleaseHandle()

internal unsafe class ReferenceHandle : Libgit2Object
{
internal ReferenceHandle()
: base()
{
}

internal ReferenceHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -36,6 +46,11 @@ protected override bool ReleaseHandle()

internal unsafe class RepositoryHandle : Libgit2Object
{
internal RepositoryHandle()
: base()
{
}

internal RepositoryHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -51,6 +66,11 @@ protected override bool ReleaseHandle()

internal unsafe class SignatureHandle : Libgit2Object
{
internal SignatureHandle()
: base()
{
}

internal SignatureHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -66,6 +86,11 @@ protected override bool ReleaseHandle()

internal unsafe class StatusListHandle : Libgit2Object
{
internal StatusListHandle()
: base()
{
}

internal StatusListHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -81,6 +106,11 @@ protected override bool ReleaseHandle()

internal unsafe class BlameHandle : Libgit2Object
{
internal BlameHandle()
: base()
{
}

internal BlameHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -96,6 +126,11 @@ protected override bool ReleaseHandle()

internal unsafe class DiffHandle : Libgit2Object
{
internal DiffHandle()
: base()
{
}

internal DiffHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -111,6 +146,11 @@ protected override bool ReleaseHandle()

internal unsafe class PatchHandle : Libgit2Object
{
internal PatchHandle()
: base()
{
}

internal PatchHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -126,6 +166,11 @@ protected override bool ReleaseHandle()

internal unsafe class ConfigurationHandle : Libgit2Object
{
internal ConfigurationHandle()
: base()
{
}

internal ConfigurationHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -141,6 +186,11 @@ protected override bool ReleaseHandle()

internal unsafe class ConflictIteratorHandle : Libgit2Object
{
internal ConflictIteratorHandle()
: base()
{
}

internal ConflictIteratorHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -156,6 +206,11 @@ protected override bool ReleaseHandle()

internal unsafe class IndexHandle : Libgit2Object
{
internal IndexHandle()
: base()
{
}

internal IndexHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -171,6 +226,11 @@ protected override bool ReleaseHandle()

internal unsafe class ReflogHandle : Libgit2Object
{
internal ReflogHandle()
: base()
{
}

internal ReflogHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -186,6 +246,11 @@ protected override bool ReleaseHandle()

internal unsafe class TreeBuilderHandle : Libgit2Object
{
internal TreeBuilderHandle()
: base()
{
}

internal TreeBuilderHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -201,6 +266,11 @@ protected override bool ReleaseHandle()

internal unsafe class PackBuilderHandle : Libgit2Object
{
internal PackBuilderHandle()
: base()
{
}

internal PackBuilderHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -216,6 +286,11 @@ protected override bool ReleaseHandle()

internal unsafe class NoteHandle : Libgit2Object
{
internal NoteHandle()
: base()
{
}

internal NoteHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -231,6 +306,11 @@ protected override bool ReleaseHandle()

internal unsafe class DescribeResultHandle : Libgit2Object
{
internal DescribeResultHandle()
: base()
{
}

internal DescribeResultHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -246,6 +326,11 @@ protected override bool ReleaseHandle()

internal unsafe class SubmoduleHandle : Libgit2Object
{
internal SubmoduleHandle()
: base()
{
}

internal SubmoduleHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -261,6 +346,11 @@ protected override bool ReleaseHandle()

internal unsafe class AnnotatedCommitHandle : Libgit2Object
{
internal AnnotatedCommitHandle()
: base()
{
}

internal AnnotatedCommitHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -276,6 +366,11 @@ protected override bool ReleaseHandle()

internal unsafe class ObjectDatabaseHandle : Libgit2Object
{
internal ObjectDatabaseHandle()
: base()
{
}

internal ObjectDatabaseHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -291,6 +386,11 @@ protected override bool ReleaseHandle()

internal unsafe class RevWalkerHandle : Libgit2Object
{
internal RevWalkerHandle()
: base()
{
}

internal RevWalkerHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -306,6 +406,11 @@ protected override bool ReleaseHandle()

internal unsafe class RemoteHandle : Libgit2Object
{
internal RemoteHandle()
: base()
{
}

internal RemoteHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -321,6 +426,11 @@ protected override bool ReleaseHandle()

internal unsafe class ObjectHandle : Libgit2Object
{
internal ObjectHandle()
: base()
{
}

internal ObjectHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -336,6 +446,11 @@ protected override bool ReleaseHandle()

internal unsafe class RebaseHandle : Libgit2Object
{
internal RebaseHandle()
: base()
{
}

internal RebaseHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -351,6 +466,11 @@ protected override bool ReleaseHandle()

internal unsafe class OdbStreamHandle : Libgit2Object
{
internal OdbStreamHandle()
: base()
{
}

internal OdbStreamHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand All @@ -366,6 +486,11 @@ protected override bool ReleaseHandle()

internal unsafe class WorktreeHandle : Libgit2Object
{
internal WorktreeHandle()
: base()
{
}

internal WorktreeHandle(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand Down
5 changes: 5 additions & 0 deletions LibGit2Sharp/Core/Handles/Objects.tt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ for (var i = 0; i < cNames.Length; i++)
#>
internal unsafe class <#= csNames[i] #> : Libgit2Object
{
internal <#= csNames[i] #>()
: base()
{
}

internal <#= csNames[i] #>(IntPtr ptr, bool owned)
: base(ptr, owned)
{
Expand Down
Loading

0 comments on commit 11aae8b

Please sign in to comment.