@@ -32,6 +32,20 @@ private static RefState TryResolveReference(out Reference reference, ReferenceCo
32
32
return reference != null ? RefState . Exists : RefState . DoesNotExistButLooksValid ;
33
33
}
34
34
35
+ /// <summary>
36
+ /// Creates a direct or symbolic reference with the specified name and target
37
+ /// </summary>
38
+ /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
39
+ /// <param name="name">The name of the reference to create.</param>
40
+ /// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
41
+ /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
42
+ /// <returns>A new <see cref="Reference"/>.</returns>
43
+ public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish ,
44
+ string logMessage )
45
+ {
46
+ return refsColl . Add ( name , canonicalRefNameOrObjectish , logMessage , false ) ;
47
+ }
48
+
35
49
/// <summary>
36
50
/// Creates a direct or symbolic reference with the specified name and target
37
51
/// </summary>
@@ -41,7 +55,7 @@ private static RefState TryResolveReference(out Reference reference, ReferenceCo
41
55
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
42
56
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
43
57
/// <returns>A new <see cref="Reference"/>.</returns>
44
- public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish , string logMessage , bool allowOverwrite = false )
58
+ public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish , string logMessage , bool allowOverwrite )
45
59
{
46
60
Ensure . ArgumentNotNullOrEmptyString ( name , "name" ) ;
47
61
Ensure . ArgumentNotNullOrEmptyString ( canonicalRefNameOrObjectish , "canonicalRefNameOrObjectish" ) ;
@@ -77,6 +91,19 @@ public static Reference Add(this ReferenceCollection refsColl, string name, stri
77
91
return refsColl . Add ( name , gitObject . Id , logMessage , allowOverwrite ) ;
78
92
}
79
93
94
+
95
+ /// <summary>
96
+ /// Creates a direct or symbolic reference with the specified name and target
97
+ /// </summary>
98
+ /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
99
+ /// <param name="name">The name of the reference to create.</param>
100
+ /// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
101
+ /// <returns>A new <see cref="Reference"/>.</returns>
102
+ public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish )
103
+ {
104
+ return Add ( refsColl , name , canonicalRefNameOrObjectish , null , false ) ;
105
+ }
106
+
80
107
/// <summary>
81
108
/// Creates a direct or symbolic reference with the specified name and target
82
109
/// </summary>
@@ -85,7 +112,7 @@ public static Reference Add(this ReferenceCollection refsColl, string name, stri
85
112
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
86
113
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
87
114
/// <returns>A new <see cref="Reference"/>.</returns>
88
- public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish , bool allowOverwrite = false )
115
+ public static Reference Add ( this ReferenceCollection refsColl , string name , string canonicalRefNameOrObjectish , bool allowOverwrite )
89
116
{
90
117
return Add ( refsColl , name , canonicalRefNameOrObjectish , null , allowOverwrite ) ;
91
118
}
@@ -122,6 +149,46 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, Referenc
122
149
return UpdateTarget ( refsColl , directRef , objectish , null ) ;
123
150
}
124
151
152
+ /// <summary>
153
+ /// Rename an existing reference with a new name
154
+ /// </summary>
155
+ /// <param name="currentName">The canonical name of the reference to rename.</param>
156
+ /// <param name="newName">The new canonical name.</param>
157
+ /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
158
+ /// <returns>A new <see cref="Reference"/>.</returns>
159
+ public static Reference Rename ( this ReferenceCollection refsColl , string currentName , string newName )
160
+ {
161
+ return refsColl . Rename ( currentName , newName , null , false ) ;
162
+ }
163
+
164
+ /// <summary>
165
+ /// Rename an existing reference with a new name
166
+ /// </summary>
167
+ /// <param name="currentName">The canonical name of the reference to rename.</param>
168
+ /// <param name="newName">The new canonical name.</param>
169
+ /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
170
+ /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
171
+ /// <returns>A new <see cref="Reference"/>.</returns>
172
+ public static Reference Rename ( this ReferenceCollection refsColl , string currentName , string newName ,
173
+ bool allowOverwrite )
174
+ {
175
+ return refsColl . Rename ( currentName , newName , null , allowOverwrite ) ;
176
+ }
177
+
178
+ /// <summary>
179
+ /// Rename an existing reference with a new name
180
+ /// </summary>
181
+ /// <param name="currentName">The canonical name of the reference to rename.</param>
182
+ /// <param name="newName">The new canonical name.</param>
183
+ /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
184
+ /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
185
+ /// <returns>A new <see cref="Reference"/>.</returns>
186
+ public static Reference Rename ( this ReferenceCollection refsColl , string currentName , string newName ,
187
+ string logMessage )
188
+ {
189
+ return refsColl . Rename ( currentName , newName , logMessage , false ) ;
190
+ }
191
+
125
192
/// <summary>
126
193
/// Rename an existing reference with a new name
127
194
/// </summary>
@@ -132,7 +199,7 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, Referenc
132
199
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
133
200
/// <returns>A new <see cref="Reference"/>.</returns>
134
201
public static Reference Rename ( this ReferenceCollection refsColl , string currentName , string newName ,
135
- string logMessage = null , bool allowOverwrite = false )
202
+ string logMessage , bool allowOverwrite )
136
203
{
137
204
Ensure . ArgumentNotNullOrEmptyString ( currentName , "currentName" ) ;
138
205
0 commit comments