@@ -8,14 +8,17 @@ namespace LibGit2Sharp
8
8
/// <summary>
9
9
/// Stores the binary content of a tracked file.
10
10
/// </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>
11
14
public class Blob : GitObject
12
15
{
13
16
private readonly ILazy < Int64 > lazySize ;
14
17
private readonly ILazy < bool > lazyIsBinary ;
15
- private readonly ILazy < bool > lazyIsDownloaded ;
18
+ private readonly ILazy < bool > lazyIsMissing ;
16
19
17
20
/// <summary>
18
- /// Needed for mocking purposes.
21
+ /// Needed for mocking purposes.s
19
22
/// </summary>
20
23
protected Blob ( )
21
24
{ }
@@ -25,7 +28,7 @@ internal Blob(Repository repo, ObjectId id)
25
28
{
26
29
lazySize = GitObjectLazyGroup . Singleton ( repo , id , Proxy . git_blob_rawsize ) ;
27
30
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 ) ;
29
32
}
30
33
31
34
/// <summary>
@@ -35,22 +38,25 @@ internal Blob(Repository repo, ObjectId id)
35
38
/// can be used.
36
39
/// </para>
37
40
/// </summary>
41
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
38
42
public virtual long Size => lazySize . Value ;
39
43
40
44
/// <summary>
41
45
/// Determine if the blob content is most certainly binary or not.
42
46
/// </summary>
47
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
43
48
public virtual bool IsBinary => lazyIsBinary . Value ;
44
49
45
50
46
51
/// <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)
48
53
/// </summary>
49
- public virtual bool IsDownloaded => lazyIsDownloaded . Value ;
54
+ public virtual bool IsMissing => lazyIsMissing . Value ;
50
55
51
56
/// <summary>
52
57
/// Gets the blob content in a <see cref="Stream"/>.
53
58
/// </summary>
59
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
54
60
public virtual Stream GetContentStream ( )
55
61
{
56
62
return Proxy . git_blob_rawcontent_stream ( repo . Handle , Id , Size ) ;
@@ -61,6 +67,7 @@ public virtual Stream GetContentStream()
61
67
/// checked out to the working directory.
62
68
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
63
69
/// </summary>
70
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
64
71
public virtual Stream GetContentStream ( FilteringOptions filteringOptions )
65
72
{
66
73
Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
@@ -72,6 +79,7 @@ public virtual Stream GetContentStream(FilteringOptions filteringOptions)
72
79
/// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected from the byte order mark
73
80
/// </summary>
74
81
/// <returns>Blob content as text.</returns>
82
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
75
83
public virtual string GetContentText ( )
76
84
{
77
85
return ReadToEnd ( GetContentStream ( ) , null ) ;
@@ -83,6 +91,7 @@ public virtual string GetContentText()
83
91
/// </summary>
84
92
/// <param name="encoding">The encoding of the text to use, if it cannot be detected</param>
85
93
/// <returns>Blob content as text.</returns>
94
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
86
95
public virtual string GetContentText ( Encoding encoding )
87
96
{
88
97
Ensure . ArgumentNotNull ( encoding , "encoding" ) ;
@@ -95,6 +104,7 @@ public virtual string GetContentText(Encoding encoding)
95
104
/// </summary>
96
105
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
97
106
/// <returns>Blob content as text.</returns>
107
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
98
108
public virtual string GetContentText ( FilteringOptions filteringOptions )
99
109
{
100
110
return GetContentText ( filteringOptions , null ) ;
@@ -109,6 +119,7 @@ public virtual string GetContentText(FilteringOptions filteringOptions)
109
119
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
110
120
/// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
111
121
/// <returns>Blob content as text.</returns>
122
+ /// <exception cref="NotFoundException">Throws if blob is missing</exception>
112
123
public virtual string GetContentText ( FilteringOptions filteringOptions , Encoding encoding )
113
124
{
114
125
Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
0 commit comments