Skip to content

Commit 966ec5a

Browse files
committed
Get rid of the index entry SafeHandle
1 parent 92fc8f5 commit 966ec5a

File tree

7 files changed

+15
-41
lines changed

7 files changed

+15
-41
lines changed

‎LibGit2Sharp/Core/GitIndexEntry.cs‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ internal unsafe struct git_index_mtime
1313
[StructLayout(LayoutKind.Sequential)]
1414
internalunsafestructgit_index_entry
1515
{
16+
internalconstushortGIT_IDXENTRY_VALID=0x8000;
17+
1618
publicgit_index_mtimectime;
1719
publicgit_index_mtimemtime;
1820
publicuintdev;
@@ -26,23 +28,4 @@ internal unsafe struct git_index_entry
2628
publicushortextended_flags;
2729
publicchar*path;
2830
}
29-
30-
[StructLayout(LayoutKind.Sequential)]
31-
internalclassGitIndexEntry
32-
{
33-
internalconstushortGIT_IDXENTRY_VALID=0x8000;
34-
35-
publicGitIndexTimeCTime;
36-
publicGitIndexTimeMTime;
37-
publicuintDev;
38-
publicuintIno;
39-
publicuintMode;
40-
publicuintUid;
41-
publicuintGid;
42-
publicuintfile_size;
43-
publicGitOidId;
44-
publicushortFlags;
45-
publicushortExtendedFlags;
46-
publicIntPtrPath;
47-
}
4831
}

‎LibGit2Sharp/Core/Handles/IndexEntrySafeHandle.cs‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎LibGit2Sharp/Core/NativeMethods.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,9 @@ internal static extern int git_index_add_bypath(
629629
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalCookie=UniqueId.UniqueIdentifier,MarshalTypeRef=typeof(StrictFilePathMarshaler))]FilePathpath);
630630

631631
[DllImport(libgit2)]
632-
internalstaticexternintgit_index_add(
632+
internalstaticexternunsafeintgit_index_add(
633633
IndexSafeHandleindex,
634-
GitIndexEntryentry);
634+
git_index_entry*entry);
635635

636636
[DllImport(libgit2)]
637637
internalstaticexternunsafeintgit_index_conflict_get(

‎LibGit2Sharp/Core/Proxy.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ public static bool git_ignore_path_is_ignored(RepositorySafeHandle repo, string
893893

894894
#region git_index_
895895

896-
publicstaticvoidgit_index_add(IndexSafeHandleindex,GitIndexEntryentry)
896+
publicstaticunsafevoidgit_index_add(IndexSafeHandleindex,git_index_entry*entry)
897897
{
898898
intres=NativeMethods.git_index_add(index,entry);
899899
Ensure.ZeroResult(res);

‎LibGit2Sharp/Index.cs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
usingSystem.Collections.Generic;
44
usingSystem.Diagnostics;
55
usingSystem.Globalization;
6+
usingSystem.Runtime.InteropServices;
67
usingLibGit2Sharp.Core;
78
usingLibGit2Sharp.Core.Handles;
89

@@ -270,17 +271,18 @@ public virtual ConflictCollection Conflicts
270271
get{returnconflicts;}
271272
}
272273

273-
privatevoidAddEntryToTheIndex(stringpath,ObjectIdid,Modemode)
274+
privateunsafevoidAddEntryToTheIndex(stringpath,ObjectIdid,Modemode)
274275
{
275-
varindexEntry=newGitIndexEntry
276+
IntPtrpathPtr=StrictFilePathMarshaler.FromManaged(path);
277+
varindexEntry=newgit_index_entry
276278
{
277-
Mode=(uint)mode,
278-
Id=id.Oid,
279-
Path=StrictFilePathMarshaler.FromManaged(path),
279+
mode=(uint)mode,
280+
path=(char*)pathPtr,
280281
};
282+
Marshal.Copy(id.RawId,0,newIntPtr(indexEntry.id.Id),GitOid.Size);
281283

282-
Proxy.git_index_add(handle,indexEntry);
283-
EncodingMarshaler.Cleanup(indexEntry.Path);
284+
Proxy.git_index_add(handle,&indexEntry);
285+
EncodingMarshaler.Cleanup(pathPtr);
284286
}
285287

286288
privatestringDebuggerDisplay

‎LibGit2Sharp/IndexEntry.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal static unsafe IndexEntry BuildFromPtr(git_index_entry* entry)
5555
Id=newObjectId(entry->id.Id),
5656
StageLevel=Proxy.git_index_entry_stage(entry),
5757
Mode=(Mode)entry->mode,
58-
AssumeUnchanged=(GitIndexEntry.GIT_IDXENTRY_VALID&entry->flags)==GitIndexEntry.GIT_IDXENTRY_VALID
58+
AssumeUnchanged=(git_index_entry.GIT_IDXENTRY_VALID&entry->flags)==git_index_entry.GIT_IDXENTRY_VALID
5959
};
6060
}
6161

‎LibGit2Sharp/LibGit2Sharp.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
<CompileInclude="Core\Handles\ObjectDatabaseSafeHandle.cs" />
285285
<CompileInclude="Core\Handles\DiffSafeHandle.cs" />
286286
<CompileInclude="Core\Handles\GitObjectSafeHandle.cs" />
287-
<CompileInclude="Core\Handles\IndexEntrySafeHandle.cs" />
288287
<CompileInclude="Core\Handles\NotOwnedSafeHandleBase.cs" />
289288
<CompileInclude="Core\Handles\OidSafeHandle.cs" />
290289
<CompileInclude="Core\Handles\TreeBuilderSafeHandle.cs" />

0 commit comments

Comments
(0)