-
Notifications
You must be signed in to change notification settings - Fork 894
/
Copy pathSymbolicReference.cs
57 lines (51 loc) · 1.81 KB
/
SymbolicReference.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
using System.Diagnostics;
using System.Globalization;
namespace LibGit2Sharp
{
/// <summary>
/// A SymbolicReference is a reference that points to another reference
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SymbolicReference : Reference
{
private readonly Reference target;
/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected SymbolicReference()
{ }
internal SymbolicReference(IRepository repo, string canonicalName, string targetIdentifier, Reference target)
: base(repo, canonicalName, targetIdentifier)
{
this.target = target;
}
/// <summary>
/// Gets the target of this <see cref="SymbolicReference"/>
/// </summary>
public virtual Reference Target
{
get { return target; }
}
/// <summary>
/// Recursively peels the target of the reference until a direct reference is encountered.
/// </summary>
/// <returns>The <see cref="DirectReference"/> this <see cref="SymbolicReference"/> points to.</returns>
public override DirectReference ResolveToDirectReference()
{
return (Target == null) ? null : Target.ResolveToDirectReference();
}
private string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
"{0} => {1} => \"{2}\"",
CanonicalName,
TargetIdentifier,
(Target != null)
? Target.TargetIdentifier
: "?");
}
}
}
}