8000 WIP · libgit2/libgit2sharp@bd703dd · GitHub
[go: up one dir, main page]

Skip to content

Commit bd703dd

Browse files
committed
WIP
1 parent 2011a43 commit bd703dd

18 files changed

+59
-97
lines changed

LibGit2Sharp/BlameHunkCollection.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Runtime.InteropServices;
65
using LibGit2Sharp.Core;
76
using LibGit2Sharp.Core.Handles;
87

@@ -35,18 +34,12 @@ internal unsafe BlameHunkCollection(Repository repo, RepositoryHandle repoHandle
3534

3635
if (options.StartingAt != null)
3736
{
38-
fixed (byte* p = rawopts.newest_commit.Id)
39-
{
40-
Marshal.Copy(repo.Committish(options.StartingAt).Oid.Id, 0, new IntPtr(p), git_oid.Size);
41-
}
37+
rawopts.newest_commit = repo.Committish(options.StartingAt).Oid;
4238
}
4339

4440
if (options.StoppingAt != null)
4541
{
46-
fixed (byte* p = rawopts.oldest_commit.Id)
47-
{
48-
Marshal.Copy(repo.Committish(options.StoppingAt).Oid.Id, 0, new IntPtr(p), git_oid.Size);
49-
}
42+
rawopts.oldest_commit = repo.Committish(options.StoppingAt).Oid;
5043
}
5144

5245
using (var blameHandle = Proxy.git_blame_file(repoHandle, path, rawopts))

LibGit2Sharp/Core/GitBlame.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,30 @@ internal enum GitBlameOptionFlags
4040
GIT_BLAME_FIRST_PARENT = (1 << 4),
4141
}
4242

43-
[StructLayout(LayoutKind.Sequential)]
44-
internal class git_blame_options
43+
internal struct git_blame_options
4544
{
45+
public git_blame_options() { }
46+
9E81
4647
public uint version = 1;
4748
public GitBlameOptionFlags flags;
4849

4950
public ushort min_match_characters;
50-
public git_oid newest_commit;
51-
public git_oid oldest_commit;
52-
public UIntPtr min_line;
53-
public UIntPtr max_line;
51+
public GitOid newest_commit;
52+
public GitOid oldest_commit;
53+
public nuint min_line;
54+
public nuint max_line;
5455
}
5556

5657
[StructLayout(LayoutKind.Sequential)]
5758
internal unsafe struct git_blame_hunk
5859
{
5960
public UIntPtr lines_in_hunk;
6061

61-
public git_oid final_commit_id;
62+
public GitOid final_commit_id;
6263
public UIntPtr final_start_line_number;
6364
public git_signature* final_signature;
64-
65-
public git_oid orig_commit_id;
65+
66+
public GitOid orig_commit_id;
6667
public char* orig_path;
6768
public UIntPtr orig_start_line_number;
6869
public git_signature* orig_signature;

LibGit2Sharp/Core/GitCheckoutOpts.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ internal delegate int perfdata_cb(
140140
IntPtr payload);
141141

142142
[StructLayout(LayoutKind.Sequential)]
143-
internal struct GitCheckoutOpts
143+
internal unsafe struct GitCheckoutOpts
144144
{
145145
public uint version;
146146

@@ -152,7 +152,7 @@ internal struct GitCheckoutOpts
152152
public int FileOpenFlags;
153153

154154
public CheckoutNotifyFlags notify_flags;
155-
public checkout_notify_cb notify_cb;
155+
public delegate* unmanaged[Cdecl]<CheckoutNotifyFlags, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, int> notify_cb;
156156
public IntPtr notify_payload;
157157

158158
public progress_cb progress_cb;

LibGit2Sharp/Core/GitDiff.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,16 @@ internal enum GitDiffFlags
250250
GIT_DIFF_FLAG_EXISTS = (1 << 3),
251251
}
252252

253-
[StructLayout(LayoutKind.Sequential)]
254253
internal unsafe struct git_diff_file
255254
{
256-
public git_oid Id;
255+
public GitOid Id;
257256
public char* Path;
258257
public long Size;
259258
public GitDiffFlags Flags;
260259
public ushort Mode;
261260
public ushort IdAbbrev;
262261
}
263262

264-
[StructLayout(LayoutKind.Sequential)]
265263
internal unsafe struct git_diff_delta
266264
{
267265
public ChangeKind status;

LibGit2Sharp/Core/GitFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ internal unsafe struct git_filter_source
122122

123123
public char* path;
124124

125-
public git_oid oid;
125+
public GitOid oid;
126126
}
127127
}

LibGit2Sharp/Core/GitIndexEntry.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
52
{
6-
[StructLayout(LayoutKind.Sequential)]
73
internal unsafe struct git_index_mtime
84
{
95
public int seconds;
106
public uint nanoseconds;
117
}
128

13-
[StructLayout(LayoutKind.Sequential)]
149
internal unsafe struct git_index_entry
1510
{
1611
internal const ushort GIT_IDXENTRY_VALID = 0x8000;
@@ -23,7 +18,7 @@ internal unsafe struct git_index_entry
2318
public uint uid;
2419
public uint gid;
2520
public uint file_size;
26-
public git_oid id;
21+
public GitOid id;
2722
public ushort flags;
2823
public ushort extended_flags;
2924
public char* path;
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
52
{
6-
[StructLayout(LayoutKind.Sequential)]
73
internal unsafe struct git_index_reuc_entry
84
{
95
public uint AncestorMode;
106
public uint OurMode;
117
public uint TheirMode;
12-
public git_oid AncestorId;
13-
public git_oid OurId;
14-
public git_oid TheirId;
8+
public GitOid AncestorId;
9+
public GitOid OurId;
10+
public GitOid TheirId;
1511
public char* Path;
1612
}
1713
}

LibGit2Sharp/Core/GitMergeOpts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal struct GitMergeOpts
3939
/// Default merge driver to be used when both sides of a merge have
4040
/// changed. The default is the `text` driver.
4141
/// </summary>
42-
public string DefaultDriver;
42+
public nint DefaultDriver;
4343

4444
/// <summary>
4545
/// Flags for automerging content.

LibGit2Sharp/Core/GitOid.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
using System.Runtime.InteropServices;
2-
3-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
42
{
5-
internal struct git_oid
6-
{
7-
public const int Size = 20;
8-
public unsafe fixed byte Id[20];
9-
}
10-
113
/// <summary>
124
/// Represents a unique id in git which is the sha1 hash of this id's content.
135
/// </summary>
@@ -21,8 +13,7 @@ internal struct GitOid
2113
/// <summary>
2214
/// The raw binary 20 byte Id.
2315
/// </summary>
24-
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Size)]
25-
public byte[] Id;
16+
public unsafe fixed byte Id[20];
2617

2718
public static implicit operator ObjectId(GitOid oid)
2819
{

LibGit2Sharp/Core/GitPushUpdate.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
52
{
6-
[StructLayout(LayoutKind.Sequential)]
73
internal unsafe struct git_push_update
84
{
95
public char* src_refname;
106
public char* dst_refname;
11-
public git_oid src;
12-
public git_oid dst;
7+
public GitOid src;
8+
public GitOid dst;
139
}
1410
}
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
52
{
6-
[StructLayout(LayoutKind.Sequential)]
73
internal unsafe struct git_rebase_operation
84
{
95
internal RebaseStepOperation type;
10-
internal git_oid id;
6+
internal GitOid id;
117
internal char* exec;
128
}
139
}

LibGit2Sharp/Core/GitRebaseOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
2-
using System.Runtime.InteropServices;
32

43
namespace LibGit2Sharp.Core
54
{
6-
[StructLayout(LayoutKind.Sequential)]
7-
internal class GitRebaseOptions
5+
internal struct GitRebaseOptions
86
{
7+
public GitRebaseOptions() { }
8+
99
public uint version = 1;
1010

1111
public int quiet;

LibGit2Sharp/Core/GitRemoteHead.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace LibGit2Sharp.Core
1+
namespace LibGit2Sharp.Core
52
{
6-
[StructLayout(LayoutKind.Sequential)]
73
internal unsafe struct git_remote_head
84
{
95
public int Local;
10-
public git_oid Oid;
11-
public git_oid Loid;
6+
public GitOid Oid;
7+
public GitOid Loid;
128
public char* Name;
139
public char* SymrefTarget;
1410
}

LibGit2Sharp/Core/GitRepositoryInitOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using System;
22
using System.Diagnostics;
3-
using System.Runtime.InteropServices;
43

54
namespace LibGit2Sharp.Core
65
{
7-
[StructLayout(LayoutKind.Sequential)]
8-
internal class GitRepositoryInitOptions : IDisposable
6+
internal struct GitRepositoryInitOptions : IDisposable
97
{
108
public uint Version = 1;
119
public GitRepositoryInitFlags Flags;
@@ -16,6 +14,8 @@ internal class GitRepositoryInitOptions : IDisposable
1614
public IntPtr InitialHead;
1715
public IntPtr OriginUrl;
1816

17+
public GitRepositoryInitOptions() { }
18+
1919
public static GitRepositoryInitOptions BuildFrom(FilePath workdirPath, bool isBare)
2020
{
2121
var opts = new GitRepositoryInitOptions

0 commit comments

Comments
 (0)
0