Skip to content

Commit 04cdfe6

Browse files
committedNov 28, 2024··
WIP
1 parent 42ac5d2 commit 04cdfe6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace LibGit2Sharp.Core.Handles;
4+
5+
internal unsafe class UnownedTreeEntryHandle : TreeEntryHandle
6+
{
7+
internal UnownedTreeEntryHandle()
8+
: base(IntPtr.Zero, false)
9+
{
10+
}
11+
12+
internal UnownedTreeEntryHandle(IntPtr ptr)
13+
: base(ptr, false)
14+
{
15+
}
16+
}

‎LibGit2Sharp/Core/NativeMethods.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ internal static extern int git_transport_unregister(
19981998
internal static extern unsafe uint git_tree_entry_filemode(TreeEntryHandle entry);
19991999

20002000
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
2001-
internal static extern unsafe TreeEntryHandle git_tree_entry_byindex(ObjectHandle tree, UIntPtr idx);
2001+
internal static extern unsafe UnownedTreeEntryHandle git_tree_entry_byindex(ObjectHandle tree, UIntPtr idx);
20022002

20032003
[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
20042004
internal static extern unsafe int git_tree_entry_bypath(

‎LibGit2Sharp/Core/Proxy.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -3188,13 +3188,7 @@ public static unsafe Mode git_tree_entry_attributes(TreeEntryHandle entry)
31883188

31893189
public static unsafe TreeEntryHandle git_tree_entry_byindex(ObjectHandle tree, long idx)
31903190
{
3191-
var handle = NativeMethods.git_tree_entry_byindex(tree, (UIntPtr)idx);
3192-
if (handle == null)
3193-
{
3194-
return null;
3195-
}
3196-
3197-
return new TreeEntryHandle(handle, false);
3191+
return NativeMethods.git_tree_entry_byindex(tree, (UIntPtr)idx);
31983192
}
31993193

32003194
public static unsafe TreeEntryHandle git_tree_entry_bypath(RepositoryHandle repo, ObjectId id, string treeentry_path)

0 commit comments

Comments
 (0)
Please sign in to comment.