@@ -102,42 +102,46 @@ - (void) showFile
102
102
NSArray *files=[historyController.treeController selectedObjects ];
103
103
if ([files count ]>0 ) {
104
104
PBGitTree *file=[files objectAtIndex: 0 ];
105
-
106
- NSString *fileTxt = @" " ;
107
- if (startFile==@" fileview" ){
108
- fileTxt=[file textContents: &theError];
109
- if (!theError)
110
- fileTxt=[GLFileView parseHTML: fileTxt];
111
- }else if (startFile==@" blame" ){
112
- fileTxt=[file blame: &theError];
113
- if (!theError)
114
- fileTxt=[self parseBlame: fileTxt];
115
- }else if (startFile==@" log" ){
116
- fileTxt=[file log: logFormat error: &theError];
117
- }else if (startFile==@" diff" ){
118
- fileTxt=[file diff: diffType error: &theError];
119
- if (!theError)
120
- fileTxt=[GLFileView parseDiff: fileTxt];
121
- }
122
-
123
- id script = [view windowScriptObject ];
124
- if (!theError){
125
- NSString *filePath = [file fullPath ];
126
- fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" \t " withString: @" " ];
127
- DLog (@" file.sha='%@ '" ,file.sha );
128
- fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA_PREV}" withString: file.sha];
129
- if (diffType==@" h" ) {
130
- fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA}" withString: @" HEAD" ];
131
- }else {
132
- fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA}" withString: @" --" ];
105
+ DLog (@" file=%@ == %@ => %d " ,file,lastFile,[file isEqualTo: lastFile]);
106
+ if (![file isEqualTo: lastFile]){
107
+ lastFile=file;
108
+
109
+ NSString *fileTxt = @" " ;
110
+ if (startFile==@" fileview" ){
111
+ fileTxt=[file textContents: &theError];
112
+ if (!theError)
113
+ fileTxt=[GLFileView parseHTML: fileTxt];
114
+ }else if (startFile==@" blame" ){
115
+ fileTxt=[file blame: &theError];
116
+ if (!theError)
117
+ fileTxt=[self parseBlame: fileTxt];
118
+ }else if (startFile==@" log" ){
119
+ fileTxt=[file log: logFormat error: &theError];
120
+ }else if (startFile==@" diff" ){
121
+ fileTxt=[file diff: diffType error: &theError];
122
+ if (!theError)
123
+ fileTxt=[GLFileView parseDiff: fileTxt];
133
124
}
134
- [script callWebScriptMethod: @" showFile" withArguments: [NSArray arrayWithObjects: fileTxt, filePath, nil ]];
135
- }else {
136
- [script callWebScriptMethod: @" setMessage" withArguments: [NSArray arrayWithObjects: [theError localizedDescription ], nil ]];
137
- }
125
+
126
+ id script = [view windowScriptObject ];
127
+ if (!theError){
128
+ NSString *filePath = [file fullPath ];
129
+ fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" \t " withString: @" " ];
130
+ DLog (@" file.sha='%@ '" ,file.sha );
131
+ fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA_PREV}" withString: file.sha];
132
+ if (diffType==@" h" ) {
133
+ fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA}" withString: @" HEAD" ];
134
+ }else {
135
+ fileTxt=[fileTxt stringByReplacingOccurrencesOfString: @" {SHA}" withString: @" --" ];
136
+ }
137
+ [script callWebScriptMethod: @" showFile" withArguments: [NSArray arrayWithObjects: fileTxt, filePath, nil ]];
138
+ }else {
139
+ [script callWebScriptMethod: @" setMessage" withArguments: [NSArray arrayWithObjects: [theError localizedDescription ], nil ]];
140
+ }
141
+ [self updateSearch: searchField];
142
+ }
138
143
}
139
144
140
- [self updateSearch: searchField];
141
145
142
146
#ifdef DEBUG_BUILD
143
147
DOMHTMLElement *dom=(DOMHTMLElement *)[[[view mainFrame ] DOMDocument ] documentElement ];
@@ -338,10 +342,10 @@ + (NSString *)parseBinaryDiff:(NSString *)txt
338
342
NSMutableString *res=[NSMutableString string ];
339
343
NSScanner *scan=[NSScanner scannerWithString: txt];
340
344
NSString *block;
341
-
345
+
342
346
[scan scanUpToString: @" Binary files" intoString: NULL ];
343
347
[scan scanUpToString: @" " intoString: &block];
344
-
348
+
345
349
NSArray *files=[self getFilesNames: block];
346
350
[res appendString: @" <tr class='images'><td>" ];
347
351
[res appendString: [NSString stringWithFormat: @" %@ <br/>" ,[files objectAtIndex: 0 ]]];
@@ -358,7 +362,7 @@ + (NSString *)parseBinaryDiff:(NSString *)txt
358
362
}
359
363
}
360
364
[res appendString: @" </td></tr>" ];
361
-
365
+
362
366
return res;
363
367
}
364
368
@@ -383,7 +387,7 @@ + (NSString *)parseDiffChunk:(NSString *)txt
383
387
384
388
l_line=abs ([[pos_l objectAtIndex: 0 ]integerValue]);
385
389
r_line=[[pos_r objectAtIndex: 0 ]integerValue];
386
-
390
+
387
391
[res appendString: [NSString stringWithFormat: @" <tr class='header'><td colspan='3'>%@ </td></tr>" ,line]];
388
392
while ((line=[lines nextObject ])){
389
393
NSString *s=[line substringToIndex: 1 ];
0 commit comments