-
Notifications
You must be signed in to change notification settings - Fork 894
/
Copy pathFilterSource.cs
66 lines (58 loc) · 2.14 KB
/
FilterSource.cs
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
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// A filter source - describes the direction of filtering and the file being filtered.
/// </summary>
public class FilterSource
{
/// <summary>
/// Needed for mocking purposes
/// </summary>
protected FilterSource() { }
internal unsafe FilterSource(FilePath path, FilterMode mode, git_filter_source* source)
{
SourceMode = mode;
ObjectId = ObjectId.BuildFromPtr(&source->oid);
Path = path.Native;
Root = Proxy.git_repository_workdir(new IntPtr(source->repository)).Native;
}
/// <summary>
/// Take an unmanaged pointer and convert it to filter source callback paramater
/// </summary>
/// <param name="ptr"></param>
/// <returns></returns>
internal static unsafe FilterSource FromNativePtr(IntPtr ptr)
{
return FromNativePtr((git_filter_source*)ptr.ToPointer());
}
/// <summary>
/// Take an unmanaged pointer and convert it to filter source callback paramater
/// </summary>
/// <param name="ptr"></param>
/// <returns></returns>
internal static unsafe FilterSource FromNativePtr(git_filter_source* ptr)
{
FilePath path = LaxFilePathMarshaler.FromNative(ptr->path) ?? FilePath.Empty;
FilterMode gitFilterSourceMode = Proxy.git_filter_source_mode(ptr);
return new FilterSource(path, gitFilterSourceMode, ptr);
}
/// <summary>
/// The filter mode for current file being filtered
/// </summary>
public virtual FilterMode SourceMode { get; private set; }
/// <summary>
/// The relative path to the file
/// </summary>
public virtual string Path { get; private set; }
/// <summary>
/// The blob id
/// </summary>
public virtual ObjectId ObjectId { get; private set; }
/// <summary>
/// The working directory
/// </summary>
public virtual string Root { get; private set; }
}
}