8000 Marshal structs and constants from diff.h · rlazev/libgit2sharp@4cef5d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cef5d3

Browse files
committed
Marshal structs and constants from diff.h
1 parent b5a6026 commit 4cef5d3

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

LibGit2Sharp/Core/GitDiff.cs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
7+
namespace LibGit2Sharp.Core
8+
{
9+
[Flags]
10+
internal enum GitDiffOptionFlags
11+
{
12+
GIT_DIFF_NORMAL = 0,
13+
GIT_DIFF_REVERSE = (1 << 0),
14+
GIT_DIFF_FORCE_TEXT = (1 << 1),
15+
GIT_DIFF_IGNORE_WHITESPACE = (1 << 2),
16+
GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1 << 3),
17+
GIT_DIFF_IGNORE_WHITESPACE_EOL = (1 << 4),
18+
GIT_DIFF_IGNORE_SUBMODULES = (1 << 5),
19+
GIT_DIFF_PATIENCE = (1 << 6),
20+
GIT_DIFF_INCLUDE_IGNORED = (1 << 7),
21+
GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
22+
}
23+
24+
[StructLayout(LayoutKind.Sequential)]
25+
internal class GitDiffOptions
26+
{
27+
public GitDiffOptionFlags Flags;
28+
public ushort ContextLines;
29+
public ushort InterhunkLines;
30+
31+
// NB: These are char*s to UTF8 strings, finna marshal them by hand
32+
public IntPtr OldPrefixString;
33+
public IntPtr NewPrefixString;
34+
35+
public UnSafeNativeMethods.git_strarray PathSpec;
36+
}
37+
38+
[Flags]
39+
internal enum GitDiffFileFlags
40+
{
41+
GIT_DIFF_FILE_VALID_OID = (1 << 0),
42+
GIT_DIFF_FILE_FREE_PATH = (1 << 1),
43+
GIT_DIFF_FILE_BINARY = (1 << 2),
44+
GIT_DIFF_FILE_NOT_BINARY = (1 << 3),
45+
GIT_DIFF_FILE_FREE_DATA = (1 << 4),
46+
GIT_DIFF_FILE_UNMAP_DATA = (1 << 5),
47+
}
48+
49+
enum GitDeltaType
50+
{
51+
GIT_DELTA_UNMODIFIED = 0,
52+
GIT_DELTA_ADDED = 1,
53+
GIT_DELTA_DELETED = 2,
54+
GIT_DELTA_MODIFIED = 3,
55+
GIT_DELTA_RENAMED = 4,
56+
GIT_DELTA_COPIED = 5,
57+
GIT_DELTA_IGNORED = 6,
58+
GIT_DELTA_UNTRACKED = 7,
59+
}
60+
61+
[StructLayout(LayoutKind.Sequential)]
62+
internal class GitDiffFile
63+
{
64+
public GitOid Oid;
65+
public IntPtr Path;
66+
public ushort Mode;
67+
public long Size;
68+
public GitDiffFileFlags Flags;
69+
}
70+
71+
[StructLayout(LayoutKind.Sequential)]
72+
internal class GitDiffDelta
73+
{
74+
public GitDiffFile OldFile;
75+
public GitDiffFile NewFile;
76+
public GitDeltaType Status;
77+
public uint Similarity;
78+
public bool Binary;
79+
}
80+
81+
enum GitDiffLineOrigin : byte
82+
{
83+
GIT_DIFF_LINE_CONTEXT = 0x20, //' ',
84+
GIT_DIFF_LINE_ADDITION = 0x2B, //'+',
85+
GIT_DIFF_LINE_D 8000 ELETION = 0x2D, //'-',
86+
GIT_DIFF_LINE_ADD_EOFNL = 0x10, //'\n', /**< LF was added at end of file */
87+
GIT_DIFF_LINE_DEL_EOFNL = 0x0, //'\0', /**< LF was removed at end of file */
88+
89+
/* these values will only be sent to a `git_diff_output_fn` */
90+
GIT_DIFF_LINE_FILE_HDR = 0x46, //'F',
91+
GIT_DIFF_LINE_HUNK_HDR = 0x48, //'H',
92+
GIT_DIFF_LINE_BINARY = 0x42, //'B',
93+
}
94+
}

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Compile Include="Core\Compat\Tuple.cs" />
5858
<Compile Include="Core\DisposableEnumerable.cs" />
5959
<Compile Include="Core\EnumExtensions.cs" />
60+
<Compile Include="Core\GitDiff.cs" />
6061
<Compile Include="Core\GitObjectExtensions.cs" />
6162
<Compile Include="Core\ReferenceExtensions.cs" />
6263
<Compile Include="Core\SignatureSafeHandle.cs" />

0 commit comments

Comments
 (0)
0