forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeEntryChanges.cs
79 lines (67 loc) · 2.26 KB
/
TreeEntryChanges.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
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Diagnostics;
using System.Globalization;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Holds the changes between two versions of a tree entry.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class TreeEntryChanges
{
/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected TreeEntryChanges()
{ }
internal TreeEntryChanges(GitDiffDelta delta)
{
Path = LaxFilePathMarshaler.FromNative(delta.NewFile.Path).Native;
OldPath = LaxFilePathMarshaler.FromNative(delta.OldFile.Path).Native;
Mode = (Mode)delta.NewFile.Mode;
OldMode = (Mode)delta.OldFile.Mode;
Oid = delta.NewFile.Id;
OldOid = delta.OldFile.Id;
Status = (delta.Status == ChangeKind.Untracked || delta.Status == ChangeKind.Ignored)
? ChangeKind.Added
: delta.Status;
}
/// <summary>
/// The new path.
/// </summary>
public virtual string Path { get; private set; }
/// <summary>
/// The new <see cref="Mode"/>.
/// </summary>
public virtual Mode Mode { get; private set; }
/// <summary>
/// The new content hash.
/// </summary>
public virtual ObjectId Oid { get; private set; }
/// <summary>
/// The kind of change that has been done (added, deleted, modified ...).
/// </summary>
public virtual ChangeKind Status { get; private set; }
/// <summary>
/// The old path.
/// </summary>
public virtual string OldPath { get; private set; }
/// <summary>
/// The old <see cref="Mode"/>.
/// </summary>
public virtual Mode OldMode { get; private set; }
/// <summary>
/// The old content hash.
/// </summary>
public virtual ObjectId OldOid { get; private set; }
private string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
"Path = {0}, File {1}",
!string.IsNullOrEmpty(Path) ? Path : OldPath, Status);
}
}
}
}