@@ -8,14 +8,17 @@ namespace LibGit2Sharp
88 /// <summary>
99 /// Stores the binary content of a tracked file.
1010 /// </summary>
11+ /// <remarks>
12+ /// Since the introduction of partially cloned repositories, blobs might be missing on your local repository (see https://git-scm.com/docs/partial-clone)
13+ /// </remarks>
1114 public class Blob : GitObject
1215 {
1316 private readonly ILazy < Int64 > lazySize ;
1417 private readonly ILazy < bool > lazyIsBinary ;
15- private readonly ILazy < bool > lazyIsDownloaded ;
18+ private readonly ILazy < bool > lazyIsMissing ;
1619
1720 /// <summary>
18- /// Needed for mocking purposes.
21+ /// Needed for mocking purposes.s
1922 /// </summary>
2023 protected Blob ( )
2124 { }
@@ -25,7 +28,7 @@ internal Blob(Repository repo, ObjectId id)
2528 {
2629 lazySize = GitObjectLazyGroup . Singleton ( repo , id , Proxy . git_blob_rawsize ) ;
2730 lazyIsBinary = GitObjectLazyGroup . Singleton ( repo , id , Proxy . git_blob_is_binary ) ;
28- lazyIsDownloaded = GitObjectLazyGroup . Singleton ( repo , id , handle => handle ! = null ) ;
31+ lazyIsMissing = GitObjectLazyGroup . Singleton ( repo , id , handle => handle = = null ) ;
2932 }
3033
3134 /// <summary>
@@ -35,22 +38,25 @@ internal Blob(Repository repo, ObjectId id)
3538 /// can be used.
3639 /// </para>
3740 /// </summary>
41+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
3842 public virtual long Size => lazySize . Value ;
3943
4044 /// <summary>
4145 /// Determine if the blob content is most certainly binary or not.
4246 /// </summary>
47+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
4348 public virtual bool IsBinary => lazyIsBinary . Value ;
4449
4550
4651 /// <summary>
47- /// Determine if the blob content was downloaded (happens with partially cloned repositories)
52+ /// Determine if the blob content is missing ( with partially cloned repositories)
4853 /// </summary>
49- public virtual bool IsDownloaded => lazyIsDownloaded . Value ;
54+ public virtual bool IsMissing => lazyIsMissing . Value ;
5055
5156 /// <summary>
5257 /// Gets the blob content in a <see cref="Stream"/>.
5358 /// </summary>
59+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
5460 public virtual Stream GetContentStream ( )
5561 {
5662 return Proxy . git_blob_rawcontent_stream ( repo . Handle , Id , Size ) ;
@@ -61,6 +67,7 @@ public virtual Stream GetContentStream()
6167 /// checked out to the working directory.
6268 /// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
6369 /// </summary>
70+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
6471 public virtual Stream GetContentStream ( FilteringOptions filteringOptions )
6572 {
6673 Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
@@ -72,6 +79,7 @@ public virtual Stream GetContentStream(FilteringOptions filteringOptions)
7279 /// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected from the byte order mark
7380 /// </summary>
7481 /// <returns>Blob content as text.</returns>
82+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
7583 public virtual string GetContentText ( )
7684 {
7785 return ReadToEnd ( GetContentStream ( ) , null ) ;
@@ -83,6 +91,7 @@ public virtual string GetContentText()
8391 /// </summary>
8492 /// <param name="encoding">The encoding of the text to use, if it cannot be detected</param>
8593 /// <returns>Blob content as text.</returns>
94+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
8695 public virtual string GetContentText ( Encoding encoding )
8796 {
8897 Ensure . ArgumentNotNull ( encoding , "encoding" ) ;
@@ -95,6 +104,7 @@ public virtual string GetContentText(Encoding encoding)
95104 /// </summary>
96105 /// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
97106 /// <returns>Blob content as text.</returns>
107+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
98108 public virtual string GetContentText ( FilteringOptions filteringOptions )
99109 {
100110 return GetContentText ( filteringOptions , null ) ;
@@ -109,6 +119,7 @@ public virtual string GetContentText(FilteringOptions filteringOptions)
109119 /// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
110120 /// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
111121 /// <returns>Blob content as text.</returns>
122+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
112123 public virtual string GetContentText ( FilteringOptions filteringOptions , Encoding encoding )
113124 {
114125 Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
0 commit comments