@@ -250,44 +250,21 @@ public static void ArgumentPositiveInt32(long argumentValue, string argumentName
250250 /// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
251251 public static void GitObjectIsNotNull ( GitObject gitObject , string identifier )
252252 {
253- Func < string , LibGit2SharpException > exceptionBuilder ;
254-
255- if ( string . Equals ( "HEAD" , identifier , StringComparison . Ordinal ) )
256- {
257- exceptionBuilder = m => new UnbornBranchException ( m ) ;
258- }
259- else
253+ if ( gitObject != null )
260254 {
261- exceptionBuilder = m => new NotFoundException ( m ) ;
255+ return ;
262256 }
263257
264- GitObjectIsNotNull ( gitObject , identifier , exceptionBuilder ) ;
265- }
266-
258+ var message = string . Format ( CultureInfo . InvariantCulture ,
259+ "No valid git object identified by '{0}' exists in the repository." ,
260+ identifier ) ;
267261
268- /// <summary>
269- /// Check that the result of a C call that returns a non-null GitObject
270- /// using the default exception builder.
271- /// <para>
272- /// The native function is expected to return a valid object value.
273- /// </para>
274- /// </summary>
275- /// <param name="gitObject">The <see cref="GitObject"/> to examine.</param>
276- /// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
277- /// <param name="exceptionBuilder">The builder which constructs an <see cref="LibGit2SharpException"/> from a message.</param>
278- public static void GitObjectIsNotNull (
279- GitObject gitObject ,
280- string identifier ,
281- Func < string , LibGit2SharpException > exceptionBuilder )
282- {
283- if ( gitObject != null )
262+ if ( string . Equals ( "HEAD" , identifier , StringComparison . Ordinal ) )
284263 {
285- return ;
264+ throw new UnbornBranchException ( message ) ;
286265 }
287266
288- throw exceptionBuilder ( string . Format ( CultureInfo . InvariantCulture ,
289- "No valid git object identified by '{0}' exists in the repository." ,
290- identifier ) ) ;
267+ throw new NotFoundException ( message ) ;
291268 }
292269 }
293270}
0 commit comments