@@ -145,7 +145,7 @@ - (NSString *) log:(NSString *)format
145
145
146
146
if ([self fileSize ] > 52428800 ) // ~50MB
147
147
return [NSString stringWithFormat: @" %@ is too big to be displayed (%d bytes)" , [self fullPath ], [self fileSize ]];
148
-
148
+
149
149
NSString *contents=[repository outputInWorkdirForArguments: [NSArray arrayWithObjects: @" log" , [NSString stringWithFormat: @" --pretty=format:%@ " ,format], @" --" , [self fullPath ], nil ]];
150
150
151
151
if ([self hasBinaryHeader: contents])
@@ -155,6 +155,35 @@ - (NSString *) log:(NSString *)format
155
155
return contents;
156
156
}
157
157
158
+ - (NSString *) diff : (NSString *)format
159
+ {
160
+ if (!leaf)
161
+ return [NSString stringWithFormat: @" This is a tree with path %@ " , [self fullPath ]];
162
+
163
+ if ([self hasBinaryAttributes ])
164
+ return [NSString stringWithFormat: @" %@ appears to be a binary file of %d bytes" , [self fullPath ], [self fileSize ]];
165
+
166
+ if ([self fileSize ] > 52428800 ) // ~50MB
167
+ return [NSString stringWithFormat: @" %@ is too big to be displayed (%d bytes)" , [self fullPath ], [self fileSize ]];
168
+
169
+ NSString *contents=@" " ;
170
+ if (format==@" p" ) {
171
+ contents=[repository outputInWorkdirForArguments: [NSArray arrayWithObjects: @" diff" , sha, [NSString stringWithFormat: @" %@ ^" ,sha],[self fullPath ], nil ]];
172
+ }else if (format==@" h" ) {
173
+ contents=[repository outputInWorkdirForArguments: [NSArray arrayWithObjects: @" diff" , sha, @" HEAD" ,[self fullPath ], nil ]];
174
+ }else if (format==@" l" ) {
175
+ contents=[repository outputInWorkdirForArguments: [NSArray arrayWithObjects: @" diff" , sha, @" --" ,[self fullPath ], nil ]];
176
+ }
177
+
178
+
179
+
180
+ if ([self hasBinaryHeader: contents])
181
+ return [NSString stringWithFormat: @" %@ appears to be a binary file of %d bytes" , [self fullPath ], [self fileSize ]];
182
+
183
+
184
+ return contents;
185
+ }
186
+
158
187
- (long long )fileSize
159
188
{
160
189
if (_fileSize)
0 commit comments