blob: fd08b991c12efb65f60fb7a40e749b796641c092 (
plain)
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
|
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 GitBlameOptions
{
public uint version = 1;
public GitBlameOptionFlags flags;
public UInt16 MinMatchCharacters;
public GitOid NewestCommit;
public GitOid OldestCommit;
public uint MinLine;
public uint MaxLine;
}
[StructLayout(LayoutKind.Sequential)]
internal class GitBlameHunk
{
public ushort LinesInHunk;
public GitOid FinalCommitId;
public ushort FinalStartLineNumber;
public IntPtr FinalSignature;
public GitOid OrigCommitId;
public IntPtr OrigPath;
public ushort OrigStartLineNumber;
public IntPtr OrigSignature;
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));
}
}
}
}
|