File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 1
- using System . Runtime . InteropServices ;
1
+ using System ;
2
+ using System . Runtime . InteropServices ;
2
3
3
4
namespace LibGit2Sharp . Core
4
5
{
@@ -16,6 +17,6 @@ internal class GitIndexEntry
16
17
public GitOid oid ;
17
18
public ushort Flags ;
18
19
public ushort ExtendedFlags ;
19
- public string Path ;
20
+ public IntPtr Path ;
20
21
}
21
22
}
Original file line number Diff line number Diff line change 1
- using System . Runtime . InteropServices ;
1
+ using System ;
2
+ using System . Runtime . InteropServices ;
2
3
3
4
namespace LibGit2Sharp . Core
4
5
{
5
6
[ StructLayout ( LayoutKind . Sequential ) ]
6
7
internal class GitSignature
7
8
{
8
- public string Name ;
9
- public string Email ;
9
+ public IntPtr Name ;
10
+ public IntPtr Email ;
10
11
public GitTime When ;
11
12
}
12
13
}
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ public class IndexEntry : IEquatable<IndexEntry>
14
14
15
15
private Func < FileStatus > state ;
16
16
17
+ private static readonly Utf8Marshaler marshaler = new Utf8Marshaler ( ) ;
18
+
17
19
/// <summary>
18
20
/// State of the version of the <see cref = "Blob" /> pointed at by this <see cref = "IndexEntry" />,
19
21
/// compared against the <see cref = "Blob" /> known from the <see cref = "Repository.Head" /> and the file in the working directory.
@@ -36,11 +38,13 @@ public FileStatus State
36
38
internal static IndexEntry CreateFromPtr ( Repository repo , IntPtr ptr )
37
39
{
38
40
var entry = ( GitIndexEntry ) Marshal . PtrToStructure ( ptr , typeof ( GitIndexEntry ) ) ;
41
+ var path = ( string ) marshaler . MarshalNativeToManaged ( entry . Path ) ;
42
+
39
43
return new IndexEntry
40
44
{
41
- Path = PosixPathHelper . ToNative ( entry . Path ) ,
45
+ Path = PosixPathHelper . ToNative ( path ) ,
42
46
Id = new ObjectId ( entry . oid ) ,
43
- state = ( ) => repo . Index . RetrieveStatus ( entry . Path )
47
+ state = ( ) => repo . Index . RetrieveStatus ( path )
44
48
} ;
45
49
}
46
50
Original file line number Diff line number Diff line change @@ -13,13 +13,17 @@ public class Signature
13
13
private readonly string name ;
14
14
private readonly string email ;
15
15
16
+ private static readonly Utf8Marshaler marshaler = new Utf8Marshaler ( ) ;
17
+
16
18
internal Signature ( IntPtr signaturePtr )
17
19
{
18
20
var handle = new GitSignature ( ) ;
19
21
Marshal . PtrToStructure ( signaturePtr , handle ) ;
20
22
21
- name = handle . Name ;
22
- email = handle . Email ;
23
+ // XXX: This is unbelievably hacky, but I can't get the
24
+ // Utf8Marshaller to work properly.
25
+ name = ( string ) marshaler . MarshalNativeToManaged ( handle . Name ) ;
26
+ email = ( string ) marshaler . MarshalNativeToManaged ( handle . Email ) ;
23
27
when = Epoch . ToDateTimeOffset ( handle . When . Time , handle . When . Offset ) ;
24
28
}
25
29
You can’t perform that action at this time.
0 commit comments