forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbolicReference.cs
More file actions
56 lines (49 loc) · 1.72 KB
/
SymbolicReference.cs
File metadata and controls
56 lines (49 loc) · 1.72 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
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(string canonicalName, string targetIdentifier, Reference target)
: base(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
{
var directReference = ResolveToDirectReference();
return string.Format(CultureInfo.InvariantCulture,
"{0} => {1} => \"{2}\"",
CanonicalName, TargetIdentifier,
(directReference != null) ? directReference.TargetIdentifier : "?");
}
}
}
}