@@ -165,6 +165,7 @@ - (void) changeContentToCommit:(PBGitCommit *)commit
165
165
}
166
166
if (isCanceled ()) return nil ;
167
167
NSMutableArray *fileDeltas = [NSMutableArray array ];
168
+ NSMutableString *fullDiff = [NSMutableString string ];
168
169
[d enumerateDeltasUsingBlock: ^(GTDiffDelta *_Nonnull delta, BOOL *_Nonnull stop) {
169
170
if (isCanceled ()) {
170
171
*stop = YES ;
@@ -181,6 +182,20 @@ - (void) changeContentToCommit:(PBGitCommit *)commit
181
182
if (patch) {
182
183
numLinesAdded = patch.addedLinesCount ;
183
184
numLinesRemoved = patch.deletedLinesCount ;
185
+ NSData *patchData = patch.patchData ;
186
+ if (patchData) {
187
+ NSString *patchString =
188
+ [[NSString alloc ] initWithData: patchData
189
+ encoding: NSUTF8StringEncoding];
190
+ if (!patchString) {
191
+ patchString =
192
+ [[NSString alloc ] initWithData: patchData
193
+ encoding: NSISOLatin1StringEncoding];
194
+ }
195
+ if (patchString) {
196
+ [fullDiff appendString: patchString];
197
+ }
198
+ }
184
199
} else {
185
200
NSLog (@" generatePatch error: %@ " , err);
186
201
}
@@ -198,6 +213,7 @@ - (void) changeContentToCommit:(PBGitCommit *)commit
198
213
if (isCanceled ()) return nil ;
199
214
return @{
200
215
@" filesInfo" : fileDeltas,
216
+ @" fullDiff" : fullDiff,
201
217
};
202
218
}
203
219
@@ -208,38 +224,7 @@ - (void)commitSummaryLoaded:(NSString *)summaryJSON forOID:(GTOID *)summaryOID
208
224
return ;
209
225
}
210
226
211
- [self .view.windowScriptObject callWebScriptMethod: @" loadCommitSummary" withArguments: @[summaryJSON]];
212
-
213
- // Now load the full diff
214
- NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects: @" show" , @" --pretty=raw" , @" -M" , @" --no-color" , currentOID.SHA, nil ];
215
-
216
- if (![PBGitDefaults showWhitespaceDifferences ])
217
- [taskArguments insertObject: @" -w" atIndex: 1 ];
218
-
219
- NSFileHandle *handle = [repository handleForArguments: taskArguments];
220
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter ];
221
- // Remove notification, in case we have another one running
222
- [nc removeObserver: self name: NSFileHandleReadToEndOfFileCompletionNotification object: nil ];
223
- [nc addObserver: self selector: @selector (commitFullDiffLoaded: ) name: NSFileHandleReadToEndOfFileCompletionNotification object: handle];
224
- [handle readToEndOfFileInBackgroundAndNotify ];
225
- }
226
-
227
- - (void )commitFullDiffLoaded: (NSNotification *)notification
228
- {
229
- [[NSNotificationCenter defaultCenter ] removeObserver: self name: NSFileHandleReadToEndOfFileCompletionNotification object: nil ];
230
-
231
- NSData *data = [[notification userInfo ] valueForKey: NSFileHandleNotificationDataItem ];
232
- if (!data)
233
- return ;
234
-
235
- NSString *fullDiff = [[NSString alloc ] initWithData: data encoding: NSUTF8StringEncoding];
236
- if (!fullDiff)
237
- fullDiff = [[NSString alloc ] initWithData: data encoding: NSISOLatin1StringEncoding];
238
-
239
- if (!fullDiff)
240
- return ;
241
-
242
- [self .view.windowScriptObject callWebScriptMethod: @" loadCommitFullDiff" withArguments: [NSArray arrayWithObject: fullDiff]];
227
+ [self .view.windowScriptObject callWebScriptMethod: @" loadCommitDiff" withArguments: @[summaryJSON]];
243
228
}
244
229
245
230
- (void )selectCommit: (NSString *)sha
0 commit comments