diff --git a/GLFileView.h b/GLFileView.h
index 6cac193..dfeb15e 100644
--- a/GLFileView.h
+++ b/GLFileView.h
@@ -31,6 +31,8 @@
+ (NSString *)parseHTML:(NSString *)txt;
+ (NSString *)parseDiff:(NSString *)txt;
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats;
++ (NSString *)getFileName:(NSString *)line;
+
+(BOOL)isStartDiff:(NSString *)line;
+(BOOL)isStartBlock:(NSString *)line;
diff --git a/GLFileView.m b/GLFileView.m
index 0a0154b..3c114f2 100644
--- a/GLFileView.m
+++ b/GLFileView.m
@@ -225,7 +225,7 @@
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats
{
- NSInteger granTotal=0;
+ NSInteger granTotal=1;
for(NSArray *stat in [stats allValues]){
NSInteger add=[[stat objectAtIndex:0] integerValue];
NSInteger rem=[[stat objectAtIndex:1] integerValue];
@@ -330,6 +330,20 @@
[res appendString:[NSString stringWithFormat:@"
%@
",line]];
}else if(inDiff){
[res appendString:[NSString stringWithFormat:@"%@
",line]];
+ if([self isBinaryFile:line]){
+ NSLog(@"line='%@'",line);
+ [res appendString:@""];
+ NSArray *files=[self getFilesNames:line];
+ NSLog(@"files='%@'",files);
+ if(![[files objectAtIndex:0] isAbsolutePath]){
+ [res appendString:[NSString stringWithFormat:@"| %@ |
",[files objectAtIndex:0]]];
+ [res appendString:[NSString stringWithFormat:@" |
",[files objectAtIndex:0]]];
+ }
+ if(![[files objectAtIndex:1] isAbsolutePath]){
+ [res appendString:[NSString stringWithFormat:@"| %@ |
",[files objectAtIndex:1]]];
+ [res appendString:[NSString stringWithFormat:@" |
",[files objectAtIndex:1]]];
+ }
+ }
}
}
if(inDiff)
@@ -337,12 +351,39 @@
return res;
}
-+(NSString *)getFileName:(NSString *)line{
++(NSString *)getFileName:(NSString *)line
+{
NSRange b = [line rangeOfString:@"b/"];
NSString *file=[line substringFromIndex:b.location+2];
return file;
}
++(NSArray *)getFilesNames:(NSString *)line
+{
+ NSString *a;
+ NSString *b;
+ NSLog(@"line='%@'",line);
+ NSScanner *scanner=[NSScanner scannerWithString:line];
+ if([scanner scanString:@"Binary files " intoString:NULL]){
+ [scanner scanUpToString:@" and" intoString:&a];
+ [scanner scanString:@"and" intoString:NULL];
+ [scanner scanUpToString:@" differ" intoString:&b];
+ }
+ if (![a isAbsolutePath]) {
+ a=[a substringFromIndex:2];
+ }
+ if (![b isAbsolutePath]) {
+ b=[b substringFromIndex:2];
+ }
+
+ return [NSArray arrayWithObjects:a,b,nil];
+}
+
++(BOOL)isBinaryFile:(NSString *)line
+{
+ return (([line length]>12) && [[line substringToIndex:12] isEqualToString:@"Binary files"]);
+}
+
+(BOOL)isStartDiff:(NSString *)line
{
return (([line length]>10) && [[line substringToIndex:10] isEqualToString:@"diff --git"]);
diff --git a/PBGitXProtocol.m b/PBGitXProtocol.m
index dcffeea..7d1e1bc 100644
--- a/PBGitXProtocol.m
+++ b/PBGitXProtocol.m
@@ -25,22 +25,28 @@
{
NSURL *url = [[self request] URL];
PBGitRepository *repo = [[self request] repository];
-
+
if(!repo) {
[[self client] URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:nil]];
return;
}
-
- NSString *specifier = [NSString stringWithFormat:@"%@:%@", [url host], [[url path] substringFromIndex:1]];
+
+ NSString *path=[[url path] substringFromIndex:1];
+ NSString *v=@"";
+ if ([[path substringToIndex:5] isEqualToString:@"prev/"]) {
+ path=[path substringFromIndex:5];
+ v=@"^";
+ }
+ NSString *specifier = [NSString stringWithFormat:@"%@%@:%@", [url host], v,path];
handle = [repo handleInWorkDirForArguments:[NSArray arrayWithObjects:@"cat-file", @"blob", specifier, nil]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishFileLoad:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
-
+
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL]
MIMEType:nil
expectedContentLength:-1
textEncodingName:nil];
-
+
[[self client] URLProtocol:self
didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m
index 8c06a7f..d38a180 100644
--- a/PBWebHistoryController.m
+++ b/PBWebHistoryController.m
@@ -116,6 +116,8 @@
NSString *html=[NSString stringWithFormat:@"%@%@%@
",header,fileList,diffs];
+ html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[currentSha string]];
+
[[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]];
#if 1