@@ -8,17 +8,17 @@ namespace LibGit2Sharp
8
8
/// </summary>
9
9
public class Branch : IEquatable < Branch >
10
10
{
11
- private readonly Repository repo ;
12
-
13
11
private static readonly LambdaEqualityHelper < Branch > equalityHelper =
14
- new LambdaEqualityHelper < Branch > ( new Func < Branch , object > [ ] { x => x . CanonicalName , x => x . Tip } ) ;
12
+ new LambdaEqualityHelper < Branch > ( new Func < Branch , object > [ ] { x => x . CanonicalName , x => x . Tip } ) ;
13
+
14
+ private readonly Repository repo ;
15
15
16
16
/// <summary>
17
17
/// Initializes a new instance of the <see cref = "Branch" /> class.
18
18
/// </summary>
19
- /// <param name= "tip">The commit which is pointed at by this Branch</param>
19
+ /// <param name = "tip">The commit which is pointed at by this Branch</param>
20
20
/// <param name = "repo">The repo.</param>
21
- /// <param name= "canonicalName">The full name of the reference</param>
21
+ /// <param name = "canonicalName">The full name of the reference</param>
22
22
internal Branch ( string canonicalName , Commit tip , Repository repo )
23
23
{
24
24
this . repo = repo ;
@@ -34,21 +34,27 @@ internal Branch(string canonicalName, Commit tip, Repository repo)
34
34
/// <summary>
35
35
/// Gets the name of this branch.
36
36
/// </summary>
37
- public string Name { get { return ShortenName ( CanonicalName ) ; } }
37
+ public string Name
38
+ {
39
+ get { return ShortenName ( CanonicalName ) ; }
40
+ }
38
41
39
42
/// <summary>
40
- /// Gets a value indicating whether this instance is a remote.
43
+ /// Gets a value indicating whether this instance is a remote.
41
44
/// </summary>
42
45
/// <value>
43
46
/// <c>true</c> if this instance is remote; otherwise, <c>false</c>.
44
47
/// </value>
45
- public bool IsRemote { get { return IsRemoteBranch ( CanonicalName ) ; } }
48
+ public bool IsRemote
49
+ {
50
+ get { return IsRemoteBranch ( CanonicalName ) ; }
51
+ }
46
52
47
53
/// <summary>
48
- /// Gets a value indicating whether this instance is current branch (HEAD) in the repository.
54
+ /// Gets a value indicating whether this instance is current branch (HEAD) in the repository.
49
55
/// </summary>
50
56
/// <value>
51
- /// <c>true</c> if this instance is current branch; otherwise, <c>false</c>.
57
+ /// <c>true</c> if this instance is current branch; otherwise, <c>false</c>.
52
58
/// </value>
53
59
public bool IsCurrentRepositoryHead
54
60
{
@@ -68,6 +74,39 @@ public CommitCollection Commits
68
74
get { return repo . Commits . StartingAt ( this ) ; }
69
75
}
70
76
77
+ #region IEquatable<Branch> Members
78
+
79
+ /// <summary>
80
+ /// Determines whether the specified <see cref = "Branch" /> is equal to the current <see cref = "Branch" />.
81
+ /// </summary>
82
+ /// <param name = "other">The <see cref = "Branch" /> to compare with the current <see cref = "Branch" />.</param>
83
+ /// <returns>True if the specified <see cref = "Branch" /> is equal to the current <see cref = "Branch" />; otherwise, false.</returns>
84
+ public bool Equals ( Branch other )
85
+ {
86
+ return equalityHelper . Equals ( this , other ) ;
87
+ }
88
+
89
+ #endregion
90
+
91
+ /// <summary>
92
+ /// Determines whether the specified <see cref = "Object" /> is equal to the current <see cref = "Branch" />.
93
+ /// </summary>
94
+ /// <param name = "obj">The <see cref = "Object" /> to compare with the current <see cref = "Branch" />.</param>
95
+ /// <returns>True if the specified <see cref = "Object" /> is equal to the current <see cref = "Branch" />; otherwise, false.</returns>
96
+ public override bool Equals ( object obj )
97
+ {
98
+ return Equals ( obj as Branch ) ;
99
+ }
100
+
101
+ /// <summary>
102
+ /// Returns the hash code for this instance.
103
+ /// </summary>
104
+ /// <returns>A 32-bit signed integer hash code.</returns>
105
+ public override int GetHashCode ( )
106
+ {
107
+ return equalityHelper . GetHashCode ( this ) ;
108
+ }
109
+
71
110
private static bool IsRemoteBranch ( string canonicalName )
72
111
{
73
112
return canonicalName . StartsWith ( "refs/remotes/" ) ;
@@ -89,50 +128,21 @@ private static string ShortenName(string branchName)
89
128
}
90
129
91
130
/// <summary>
92
- /// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="Branch"/>.
93
- /// </summary>
94
- /// <param name="obj">The <see cref="Object"/> to compare with the current <see cref="Branch"/>.</param>
95
- /// <returns>True if the specified <see cref="Object"/> is equal to the current <see cref="Branch"/>; otherwise, false.</returns>
96
- public override bool Equals ( object obj )
97
- {
98
- return Equals ( obj as Branch ) ;
99
- }
100
-
101
- /// <summary>
102
- /// Determines whether the specified <see cref="Branch"/> is equal to the current <see cref="Branch"/>.
103
- /// </summary>
104
- /// <param name="other">The <see cref="Branch"/> to compare with the current <see cref="Branch"/>.</param>
105
- /// <returns>True if the specified <see cref="Branch"/> is equal to the current <see cref="Branch"/>; otherwise, false.</returns>
106
- public bool Equals ( Branch other )
107
- {
108
- return equalityHelper . Equals ( this , other ) ;
109
- }
110
-
111
- /// <summary>
112
- /// Returns the hash code for this instance.
113
- /// </summary>
114
- /// <returns>A 32-bit signed integer hash code.</returns>
115
- public override int GetHashCode ( )
116
- {
117
- return equalityHelper . GetHashCode ( this ) ;
118
- }
119
-
120
- /// <summary>
121
- /// Tests if two <see cref="Branch"/> are equal.
131
+ /// Tests if two <see cref = "Branch" /> are equal.
122
132
/// </summary>
123
- /// <param name= "left">First <see cref= "Branch"/> to compare.</param>
124
- /// <param name= "right">Second <see cref= "Branch"/> to compare.</param>
133
+ /// <param name = "left">First <see cref = "Branch" /> to compare.</param>
134
+ /// <param name = "right">Second <see cref = "Branch" /> to compare.</param>
125
135
/// <returns>True if the two objects are equal; false otherwise.</returns>
126
136
public static bool operator == ( Branch left , Branch right )
127
137
{
128
138
return Equals ( left , right ) ;
129
139
}
130
140
131
141
/// <summary>
132
- /// Tests if two <see cref= "Branch"/> are different.
142
+ /// Tests if two <see cref = "Branch" /> are different.
133
143
/// </summary>
134
- /// <param name= "left">First <see cref= "Branch"/> to compare.</param>
135
- /// <param name= "right">Second <see cref= "Branch"/> to compare.</param>
144
+ /// <param name = "left">First <see cref = "Branch" /> to compare.</param>
145
+ /// <param name = "right">Second <see cref = "Branch" /> to compare.</param>
136
146
/// <returns>True if the two objects are different; false otherwise.</returns>
137
147
public static bool operator != ( Branch left , Branch right )
138
148
{
0 commit comments