forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitBlame.cs
More file actions
88 lines (75 loc) · 2.76 KB
/
GitBlame.cs
File metadata and controls
88 lines (75 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Globalization;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core
{
[Flags]
internal enum GitBlameOptionFlags
{
/// <summary>
/// Normal blame, the default
/// </summary>
GIT_BLAME_NORMAL = 0,
/// <summary>
/// Track lines that have moved within a file (like `git blame -M`).
/// </summary>
GIT_BLAME_TRACK_COPIES_SAME_FILE = (1 << 0),
/** Track lines that have moved across files in the same commit (like `git blame -C`).
* NOT IMPLEMENTED. */
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1 << 1),
/// <summary>
/// Track lines that have been copied from another file that exists in the
/// same commit (like `git blame -CC`). Implies SAME_FILE.
/// </summary>
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1 << 2),
/// <summary>
/// Track lines that have been copied from another file that exists in *any*
/// commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES.
/// </summary>
GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1 << 3),
/// <summary>
/// Restrict the search of commits to those reachable
/// following only the first parents.
/// </summary>
GIT_BLAME_FIRST_PARENT = (1 << 4),
}
[StructLayout(LayoutKind.Sequential)]
internal class git_blame_options
{
public uint version = 1;
public GitBlameOptionFlags flags;
public UInt16 min_match_characters;
public git_oid newest_commit;
public git_oid oldest_commit;
public uint min_line;
public uint max_line;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct git_blame_hunk
{
public ushort lines_in_hunk;
public git_oid final_commit_id;
public ushort final_start_line_number;
public git_signature* final_signature;
public git_oid orig_commit_id;
public char* orig_path;
public ushort orig_start_line_number;
public git_signature* orig_signature;
public byte boundary;
}
internal static class BlameStrategyExtensions
{
public static GitBlameOptionFlags ToGitBlameOptionFlags(this BlameStrategy strategy)
{
switch (strategy)
{
case BlameStrategy.Default:
return GitBlameOptionFlags.GIT_BLAME_NORMAL;
default:
throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture,
"{0} is not supported at this time",
strategy));
}
}
}
}