Skip to content

Commit 59fb988

Browse files
committed
Throws NotFoundException
1 parent e869df5 commit 59fb988

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

LibGit2Sharp/Core/GitObjectLazyGroup.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public static ILazy<TResult> Singleton<TResult>(Repository repo, ObjectId id, Fu
2727
{
2828
using (var osw = new ObjectSafeWrapper(id, repo.Handle))
2929
{
30+
if (osw.ObjectPtr == null)
31+
throw new NotFoundException($"Blob {id} is not available");
32+
3033
return resultSelector(osw.ObjectPtr);
3134
}
3235
});

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static unsafe UnmanagedMemoryStream git_blob_filtered_content_stream(Repo
7373
{
7474
var handle = new ObjectSafeWrapper(id, repo).ObjectPtr;
7575
if (handle == null)
76-
return null;
76+
throw new NotFoundException($"Blob {id} is not available");
7777

7878
var buf = new GitBuf();
7979
return new RawContentStream(handle, h =>
@@ -89,24 +89,18 @@ public static unsafe UnmanagedMemoryStream git_blob_rawcontent_stream(Repository
8989
{
9090
var handle = new ObjectSafeWrapper(id, repo).ObjectPtr;
9191
if (handle == null)
92-
return null;
92+
throw new NotFoundException($"Blob {id} is not available");
9393

9494
return new RawContentStream(handle, h => NativeMethods.git_blob_rawcontent(h), h => size);
9595
}
9696

9797
public static unsafe long git_blob_rawsize(ObjectHandle obj)
9898
{
99-
if (obj == null)
100-
return 0;
101-
10299
return NativeMethods.git_blob_rawsize(obj);
103100
}
104101

105102
public static unsafe bool git_blob_is_binary(ObjectHandle obj)
106103
{
107-
if (obj == null)
108-
return false;
109-
110104
int res = NativeMethods.git_blob_is_binary(obj);
111105
Ensure.BooleanResult(res);
112106

0 commit comments

Comments
 (0)