diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index 6aba53d..fd43be8 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -2,13 +2,13 @@ 1050 - 10H574 - 804 + 10J567 + 851 1038.35 - 461.00 + 462.00 com.apple.InterfaceBuilder.CocoaPlugin - 804 + 851 YES @@ -43,6 +43,37 @@ 268 YES + + + 268 + {{18, 193}, {158, 18}} + + YES + + -2080244224 + 0 + Refresh automatically + + LucidaGrande + 13 + 1044 + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + 268 @@ -53,11 +84,7 @@ 68288064 272630784 Reset all dialog warnings: - - LucidaGrande - 13 - 1044 - + 6 @@ -160,13 +187,8 @@ 1211912703 2 - - NSImage - NSSwitch - - - NSSwitch - + + 200 @@ -274,7 +296,7 @@ 1211912703 2 - + @@ -285,7 +307,7 @@ 268 - {{18, 193}, {279, 18}} + {{18, 218}, {279, 18}} YES @@ -296,7 +318,7 @@ 1211912703 2 - + @@ -307,7 +329,7 @@ 268 - {{18, 218}, {207, 18}} + {{18, 243}, {207, 18}} YES @@ -318,7 +340,7 @@ 1211912703 2 - + @@ -327,7 +349,7 @@ - {400, 254} + {401, 279} NSView @@ -366,7 +388,7 @@ 1211912703 2 - + @@ -506,7 +528,7 @@ - EEEE, MMMM d, yyyy h:mm:ss a + EEEE, dd MMMM, yyyy HH:mm:ss NO @@ -557,7 +579,7 @@ 1211912703 2 - + @@ -573,6 +595,10 @@ SUUpdater + + YES + PBRefreshAutomatically + YES @@ -594,7 +620,7 @@ 1211912703 2 - + @@ -616,7 +642,7 @@ 1211912703 2 - + @@ -638,7 +664,7 @@ 1211912703 2 - + @@ -660,7 +686,7 @@ 1211912703 2 - + @@ -1079,6 +1105,22 @@ 140 + + + value: values.PBRefreshAutomatically + + + + + + value: values.PBRefreshAutomatically + value + values.PBRefreshAutomatically + 2 + + + 144 + @@ -1124,6 +1166,7 @@ + General @@ -1543,6 +1586,20 @@ + + 141 + + + YES + + + + + + 142 + + + @@ -1581,6 +1638,9 @@ 138.IBPluginDependency 139.IBPluginDependency 14.IBPluginDependency + 141.IBPluginDependency + 141.IBViewBoundsToFrameTransform + 142.IBPluginDependency 15.IBEditorWindowLastContentRect 15.IBPluginDependency 16.IBPluginDependency @@ -1623,7 +1683,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{845, 630}, {400, 254}} + {{511, 548}, {401, 279}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -1672,6 +1732,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAADBcAAAw3QAAA + + com.apple.InterfaceBuilder.CocoaPlugin {{443, 712}, {103, 71}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1735,7 +1800,7 @@ - 140 + 144 diff --git a/GLFileView.h b/GLFileView.h index dfeb15e..7dd9125 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -36,6 +36,11 @@ +(BOOL)isStartDiff:(NSString *)line; +(BOOL)isStartBlock:(NSString *)line; ++(NSArray *)getFilesNames:(NSString *)line; ++(BOOL)isBinaryFile:(NSString *)line; ++(NSString*)mimeTypeForFileName:(NSString*)file; ++(BOOL)isImage:(NSString*)file; + @property(retain) NSMutableArray *groups; @property(retain) NSString *logFormat; diff --git a/GLFileView.m b/GLFileView.m index 3c114f2..1598044 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -181,7 +181,6 @@ - (void)scopeBar:(MGScopeBar *)theScopeBar selectedStateChanged:(BOOL)selected forItem:(NSString *)identifier inGroup:(int)groupNumber { - NSLog(@"startFile=%@ identifier=%@ groupNumber=%d",startFile,identifier,groupNumber); if((groupNumber==0) && (startFile!=identifier)){ NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier]; NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path]; @@ -238,11 +237,10 @@ NSArray *lines = [txt componentsSeparatedByString:@"\n"]; NSMutableString *res=[NSMutableString string]; [res appendString:@""]; - int i; - for (i=1; i<[lines count]; i++) { - NSString *line=[lines objectAtIndex:i]; - NSArray *fields=[line componentsSeparatedByString:@" "]; - NSArray *fileStatus=[[fields objectAtIndex:4] componentsSeparatedByString:@"\t"]; + for (NSString *line in lines) { + if([line length]<98) continue; + line=[line substringFromIndex:97]; + NSArray *fileStatus=[line componentsSeparatedByString:@"\t"]; NSString *status=[[fileStatus objectAtIndex:0] substringToIndex:1]; // ignore the score NSString *file=[fileStatus objectAtIndex:1]; NSString *txt=file; @@ -255,7 +253,6 @@ NSArray *stat=[stats objectForKey:fileName]; NSInteger add=[[stat objectAtIndex:0] integerValue]; NSInteger rem=[[stat objectAtIndex:1] integerValue]; - NSInteger tot=add+rem; [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([GLFileView isImage:[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([GLFileView isImage:[files objectAtIndex:1]]){ + [res appendString:[NSString stringWithFormat:@"",[files objectAtIndex:1]]]; + } } } } @@ -360,9 +359,8 @@ +(NSArray *)getFilesNames:(NSString *)line { - NSString *a; - NSString *b; - NSLog(@"line='%@'",line); + NSString *a = nil; + NSString *b = nil; NSScanner *scanner=[NSScanner scannerWithString:line]; if([scanner scanString:@"Binary files " intoString:NULL]){ [scanner scanUpToString:@" and" intoString:&a]; @@ -375,10 +373,34 @@ if (![b isAbsolutePath]) { b=[b substringFromIndex:2]; } - + return [NSArray arrayWithObjects:a,b,nil]; } ++(NSString*)mimeTypeForFileName:(NSString*)name +{ + NSString *mimeType = nil; + NSInteger i=[name rangeOfString:@"." options:NSBackwardsSearch].location; + if(i!=NSNotFound){ + NSString *ext=[name substringFromIndex:i+1]; + CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)ext, NULL); + if(UTI){ + CFStringRef registeredType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType); + if(registeredType){ + mimeType = NSMakeCollectable(registeredType); + } + CFRelease(UTI); + } + } + return mimeType; +} + ++(BOOL)isImage:(NSString*)file +{ + NSString *mimeType=[GLFileView mimeTypeForFileName:file]; + return (mimeType!=nil) && ([mimeType rangeOfString:@"image/" options:NSCaseInsensitiveSearch].location!=NSNotFound); +} + +(BOOL)isBinaryFile:(NSString *)line { return (([line length]>12) && [[line substringToIndex:12] isEqualToString:@"Binary files"]); diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index bf7a93e..fbaf896 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -1804,10 +1804,12 @@ GCC_ENABLE_OBJC_GC = required; GCC_PREPROCESSOR_DEFINITIONS = DEBUG; GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = DEBUG_BUILD; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_PREPROCESS = YES; PREBINDING = NO; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; }; name = Debug; @@ -1821,11 +1823,13 @@ x86_64, ); GCC_ENABLE_OBJC_GC = required; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision; INFOPLIST_PREPROCESS = YES; PREBINDING = NO; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; }; name = Release; diff --git a/PBGitDefaults.h b/PBGitDefaults.h index a95b524..6fff110 100644 --- a/PBGitDefaults.h +++ b/PBGitDefaults.h @@ -18,6 +18,7 @@ + (BOOL) confirmPublicGists; + (BOOL) isGistPublic; + (BOOL)showWhitespaceDifferences; ++ (BOOL)refreshAutomatically; + (BOOL)openCurDirOnLaunch; + (BOOL)showOpenPanelOnLaunch; + (BOOL) shouldCheckoutBranch; @@ -41,4 +42,5 @@ + (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog; + (void)resetAllDialogWarnings; + @end diff --git a/PBGitDefaults.m b/PBGitDefaults.m index 5656469..f6af844 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -17,6 +17,7 @@ #define kConfirmPublicGists @"PBConfirmPublicGists" #define kPublicGist @"PBGistPublic" #define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences" +#define kRefreshAutomatically @"PBRefreshAutomatically" #define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch" #define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch" #define kShouldCheckoutBranch @"PBShouldCheckoutBranch" @@ -28,6 +29,7 @@ #define kHistorySearchMode @"PBHistorySearchMode" #define kSuppressedDialogWarnings @"Suppressed Dialog Warnings" + @implementation PBGitDefaults + (void)initialize @@ -38,19 +40,21 @@ [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kCommitMessageViewHasVerticalLine]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kEnableGist]; + forKey:kEnableGist]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kEnableGravatar]; + forKey:kEnableGravatar]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kConfirmPublicGists]; + forKey:kConfirmPublicGists]; [defaultValues setObject:[NSNumber numberWithBool:NO] - forKey:kPublicGist]; + forKey:kPublicGist]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kShowWhitespaceDifferences]; + forKey:kShowWhitespaceDifferences]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kOpenCurDirOnLaunch]; + forKey:kRefreshAutomatically]; [defaultValues setObject:[NSNumber numberWithBool:YES] - forKey:kShowOpenPanelOnLaunch]; + forKey:kOpenCurDirOnLaunch]; + [defaultValues setObject:[NSNumber numberWithBool:YES] + forKey:kShowOpenPanelOnLaunch]; [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kShouldCheckoutBranch]; [defaultValues setObject:[NSNumber numberWithBool:NO] @@ -90,10 +94,15 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:kPublicGist]; } -+ (BOOL)showWhitespaceDifferences ++ (BOOL) showWhitespaceDifferences { return [[NSUserDefaults standardUserDefaults] boolForKey:kShowWhitespaceDifferences]; } + ++ (BOOL) refreshAutomatically +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kRefreshAutomatically]; +} + (BOOL)openCurDirOnLaunch { diff --git a/PBGitHistoryList.m b/PBGitHistoryList.m index 0a4433f..0ab1324 100644 --- a/PBGitHistoryList.m +++ b/PBGitHistoryList.m @@ -287,7 +287,7 @@ - (BOOL) haveRefsBeenModified { - [repository reloadRefs]; + //[repository reloadRefs]; NSMutableSet *currentRefSHAs = [NSMutableSet setWithArray:[repository.refs allKeys]]; [currentRefSHAs minusSet:lastRefSHAs]; diff --git a/PBGitRepository.h b/PBGitRepository.h index ed14a73..63fb753 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -146,8 +146,8 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (void)findInModeScriptCommand:(NSScriptCommand *)command; -(NSNumber *)countCommintsOf:(NSString *)branchs; -+(bool)isLocalBranch:(NSString *)name; - (NSMenu *) menu; ++(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name; @property (assign) BOOL hasChanged; @property (readonly) PBGitWindowController *windowController; diff --git a/PBGitRepository.m b/PBGitRepository.m index 37fb693..50be481 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -300,10 +300,6 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]]; PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef]; - if([PBGitRepository isLocalBranch:[components objectAtIndex:0]]){ - [revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin..%@",[components objectAtIndex:0]]]]; - [revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin",[components objectAtIndex:0]]]]; - } [self addBranch:revSpec]; [self addRef:newRef fromParameters:components]; [oldBranches removeObject:revSpec]; @@ -322,21 +318,14 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [[[self windowController] window] setTitle:[self displayName]]; } -+(bool)isLocalBranch:(NSString *)name ++(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name { - NSScanner *scanner=[NSScanner scannerWithString:name]; - return [scanner scanString:@"refs/heads/" intoString:NULL]; -} - --(NSNumber *)countCommintsOf:(NSString *)branchs -{ - NSArray *args = [NSArray arrayWithObjects:@"rev-list", branchs, nil]; - NSString *o = [self outputForArguments:args]; - if ([o length]==0) { - return NULL; + NSScanner *scanner=[NSScanner scannerWithString:branch]; + bool is=[scanner scanString:@"refs/heads/" intoString:NULL]; + if(is && (name)){ + *name=[branch substringFromIndex:[scanner scanLocation]]; } - NSArray *commits = [o componentsSeparatedByString:@"\n"]; - return [NSNumber numberWithInt:[commits count]]; + return is; } - (void) lazyReload diff --git a/PBGitSVBranchItem.h b/PBGitSVBranchItem.h index c5e4538..cf1d56f 100644 --- a/PBGitSVBranchItem.h +++ b/PBGitSVBranchItem.h @@ -11,9 +11,15 @@ @interface PBGitSVBranchItem : PBSourceViewItem { - + BOOL isCheckedOut; + NSNumber *behind; + NSNumber *ahead; } + (id)branchItemWithRevSpec:(PBGitRevSpecifier *)revSpecifier; +@property (assign) BOOL isCheckedOut; +@property (assign) NSNumber *behind; +@property (assign) NSNumber *ahead; + @end diff --git a/PBGitSVBranchItem.m b/PBGitSVBranchItem.m index 6723096..3cf0389 100644 --- a/PBGitSVBranchItem.m +++ b/PBGitSVBranchItem.m @@ -11,6 +11,8 @@ @implementation PBGitSVBranchItem +@synthesize isCheckedOut; +@synthesize behind,ahead; + (id)branchItemWithRevSpec:(PBGitRevSpecifier *)revSpecifier { @@ -30,4 +32,17 @@ return branchImage; } + +- (NSString *) badge{ + NSMutableString *badge=nil; + if(isCheckedOut || ahead || behind){ + badge=[NSMutableString string]; + if(isCheckedOut) [badge appendString:@"✔ "]; + if(ahead) [badge appendFormat:@"+%@",ahead]; + if(behind) [badge appendFormat:@"-%@",behind]; + } + return badge; +} + + @end diff --git a/PBGitSVRemoteItem.h b/PBGitSVRemoteItem.h index a64084c..8f27532 100644 --- a/PBGitSVRemoteItem.h +++ b/PBGitSVRemoteItem.h @@ -11,9 +11,11 @@ @interface PBGitSVRemoteItem : PBSourceViewItem { - + BOOL alert; } +@property (assign) BOOL alert; + + (id)remoteItemWithTitle:(NSString *)title; @end diff --git a/PBGitSVRemoteItem.m b/PBGitSVRemoteItem.m index 4ce251d..0947cfd 100644 --- a/PBGitSVRemoteItem.m +++ b/PBGitSVRemoteItem.m @@ -12,6 +12,7 @@ @implementation PBGitSVRemoteItem +@synthesize alert; + (id)remoteItemWithTitle:(NSString *)title { @@ -38,4 +39,8 @@ return [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:self.title]]; } +- (NSString *)badge +{ + return (alert ? @"!" : nil); +} @end diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index ba7ab35..4126ff9 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -47,6 +47,9 @@ - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode; +-(NSNumber *)countCommintsOf:(NSString *)range; +-(bool)remoteNeedFetch:(NSString *)remote; + @property(readonly) NSMutableArray *items; @property(readonly) NSView *sourceListControlsView; @property(readonly) PBGitHistoryController *historyViewController; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 4e207d3..8c1be2c 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -61,6 +61,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController]; commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController]; + [repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"]; [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"]; [repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"]; [repository addObserver:self forKeyPath:@"stashController.stashes" options:NSKeyValueObservingOptionNew context:kObservingContextStashes]; @@ -96,7 +97,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; if ([@"currentBranchChange" isEqualToString:context]) { [sourceView reloadData]; [self selectCurrentBranch]; - } else if ([@"branchesModified" isEqualToString:context]) { + }else if ([@"branchesModified" isEqualToString:context]) { NSInteger changeKind = [(NSNumber *)[change objectForKey:NSKeyValueChangeKindKey] intValue]; if (changeKind == NSKeyValueChangeInsertion) { @@ -147,11 +148,49 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; [sourceView PBExpandItem:item expandParents:YES]; } [sourceView reloadData]; - } else { + }else if ([@"updateRefs" isEqualToString:context]) { + for(PBGitSVRemoteItem* remote in [remotes children]){ + NSLog(@"remote.title=%@",[remote title]); + [remote setAlert:[self remoteNeedFetch:[remote title]]]; + } + + for(PBGitSVBranchItem* branch in [branches children]){ + NSString *bName=[branch title]; + [branch setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin/%@..%@",bName,bName]]]; + [branch setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin/%@",bName,bName]]]; + [branch setIsCheckedOut:[branch.revSpecifier isEqual:[repository headRef]]]; + } + + }else{ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } +#pragma mark Badges Methods + +-(NSNumber *)countCommintsOf:(NSString *)range +{ + NSArray *args = [NSArray arrayWithObjects:@"rev-list", range, nil]; + int ret; + NSString *o = [repository outputForArguments:args retValue:&ret]; + if ((ret!=0) || ([o length]==0)) { + return NULL; + } + NSArray *commits = [o componentsSeparatedByString:@"\n"]; + return [NSNumber numberWithInt:[commits count]]; +} + + +-(bool)remoteNeedFetch:(NSString *)remote +{ + int ret; + NSArray *args = [NSArray arrayWithObjects:@"fetch", @"--dry-run", remote, nil]; + NSString *o = [repository outputForArguments:args retValue:&ret]; + return ((ret==0) && ([o length]!=0)); +} + +#pragma mark ----- + - (PBSourceViewItem *) selectedItem { NSInteger index = [sourceView selectedRow]; @@ -284,15 +323,6 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item { - if(item.revSpecifier!=NULL){ - cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]]; - cell.behind=[item.revSpecifier behind]; - cell.ahead=[item.revSpecifier ahead]; - }else{ - cell.behind=nil; - cell.ahead=nil; - } - BOOL showsActionButton = NO; if ([item respondsToSelector:@selector(showsActionButton)]) { showsActionButton = [item showsActionButton]; @@ -301,6 +331,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; } cell.showsActionButton = showsActionButton; + [cell setBadge:[item badge]]; [cell setImage:[item icon]]; } diff --git a/PBGitTree.m b/PBGitTree.m index 2f7af52..c966fa5 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -131,7 +131,9 @@ if(error==nil){ res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", sha, @"--", [self fullPath], nil]]; }else{ - *anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + if (anError != NULL) { + *anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + } } return res; @@ -147,7 +149,9 @@ if(error==nil){ res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"log", [NSString stringWithFormat:@"--pretty=format:%@",format], @"--", [self fullPath], nil]]; }else{ - *anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + if (anError != NULL) { + *anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + } } return res; @@ -178,12 +182,16 @@ res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", sha, des,[self fullPath], nil]]; if ([res length]==0) { NSLog(@"--%d",[res length]); - *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]]; + if (anError != NULL) { + *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]]; + } }else{ NSLog(@"--%@",[res substringToIndex:80]); } }else{ - *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + if (anError != NULL) { + *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + } } return res; @@ -205,7 +213,9 @@ if(error==nil){ res = [self contents]; }else{ - *anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + if (anError != NULL) { + *anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]]; + } } return res; diff --git a/PBGitWindowController.h b/PBGitWindowController.h index 0f38e22..9b008fc 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -25,8 +25,6 @@ IBOutlet NSTextField *statusField; IBOutlet NSProgressIndicator *progressIndicator; - PBViewController* viewController; - IBOutlet NSToolbarItem *terminalItem; IBOutlet NSToolbarItem *finderItem; } diff --git a/PBGitWindowController.m b/PBGitWindowController.m index ba926be..b08dfc2 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -9,6 +9,7 @@ #import "PBGitWindowController.h" #import "PBGitHistoryController.h" #import "PBGitCommitController.h" +#import "PBGitDefaults.h" #import "Terminal.h" #import "PBCloneRepsitoryToSheet.h" #import "PBCommitHookFailedSheet.h" @@ -132,6 +133,14 @@ [[NSAlert alertWithError:error] beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:nil contextInfo:nil]; } + +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + if ([PBGitDefaults refreshAutomatically]) { + [contentController refresh:nil]; + } +} + - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output { NSString *command = [arguments componentsJoinedByString:@" "]; diff --git a/PBSourceViewCell.h b/PBSourceViewCell.h index 5372b5a..f226525 100644 --- a/PBSourceViewCell.h +++ b/PBSourceViewCell.h @@ -9,22 +9,17 @@ #import #import "PBIconAndTextCell.h" - @interface PBSourceViewCell : PBIconAndTextCell { - BOOL isCheckedOut; - NSNumber *behind; - NSNumber *ahead; BOOL showsActionButton; BOOL iMouseDownInInfoButton; BOOL iMouseHoveredInInfoButton; SEL iInfoButtonAction; + NSString *badge; } + @property (nonatomic) BOOL showsActionButton; @property (nonatomic) SEL iInfoButtonAction; -@property (assign) BOOL isCheckedOut; -@property (assign) NSNumber *behind; -@property (assign) NSNumber *ahead; - +@property (assign) NSString *badge; @end diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index cc97f55..88c9852 100644 --- a/PBSourceViewCell.m +++ b/PBSourceViewCell.m @@ -17,10 +17,10 @@ @implementation PBSourceViewCell @synthesize iInfoButtonAction; -@synthesize isCheckedOut; -@synthesize behind,ahead; @synthesize showsActionButton; +@synthesize badge; + # pragma mark context menu delegate methods - init { @@ -45,11 +45,7 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)outlineView { - if(behind || ahead || isCheckedOut){ - NSMutableString *badge=[NSMutableString string]; - if(isCheckedOut) [badge appendString:@"✔ "]; - if(ahead) [badge appendFormat:@"+%@",ahead]; - if(behind) [badge appendFormat:@"-%@",behind]; + if(badge){ NSImage *checkedOutImage = [PBSourceViewBadge badge:badge forCell:self]; NSSize imageSize = [checkedOutImage size]; NSRect imageFrame; diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index cf97d4b..1547fd6 100644 --- a/PBSourceViewItem.h +++ b/PBSourceViewItem.h @@ -29,6 +29,8 @@ + (id)itemWithRevSpec:(PBGitRevSpecifier *)revSpecifier; + (id)itemWithTitle:(NSString *)title; +- (NSString *)badge; + - (void)addChild:(PBSourceViewItem *)child; - (void)removeChild:(PBSourceViewItem *)child; diff --git a/PBSourceViewItem.m b/PBSourceViewItem.m index aa756e0..8c810c0 100644 --- a/PBSourceViewItem.m +++ b/PBSourceViewItem.m @@ -110,6 +110,11 @@ return nil; } +- (NSString *)badge +{ + return nil; +} + - (NSImage *) icon { return nil; diff --git a/PBViewController.h b/PBViewController.h index c523de7..ec5dbd4 100644 --- a/PBViewController.h +++ b/PBViewController.h @@ -37,6 +37,6 @@ - (void)viewLoaded; - (NSResponder *)firstResponder; -- (IBAction) refresh:(id)sender; +- (IBAction) refresh:(id)sender; @end diff --git a/PBViewController.m b/PBViewController.m index 82f6f7c..77e4f3f 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -44,15 +44,16 @@ return nil; } -- (IBAction) refresh: sender -{ -} - // The next methods should be implemented in the subclass if necessary - (void)updateView { } +- (IBAction) refresh:(id)sender +{ + return; +} + - (void)viewLoaded { } diff --git a/html/lib/md5.js b/html/lib/md5.js index 36fc1c2..46d2aab 100644 --- a/html/lib/md5.js +++ b/html/lib/md5.js @@ -1,256 +1,256 @@ -/* - * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message - * Digest Algorithm, as defined in RFC 1321. - * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for more info. - */ - -/* - * Configurable variables. You may need to tweak these to be compatible with - * the server-side, but the defaults work in most cases. - */ -var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ -var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ -var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ - -/* - * These are the functions you'll usually want to call - * They take string arguments and return either hex or base-64 encoded strings - */ -function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} -function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} -function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} -function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } -function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } -function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } - -/* - * Perform a simple self-test to see if the VM is working - */ -function md5_vm_test() -{ - return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; -} - -/* - * Calculate the MD5 of an array of little-endian words, and a bit length - */ -function core_md5(x, len) -{ - /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); - x[(((len + 64) >>> 9) << 4) + 14] = len; - - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - - for(var i = 0; i < x.length; i += 16) - { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - - a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); - d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); - c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); - b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); - a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); - d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); - c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); - b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); - a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); - d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); - c = md5_ff(c, d, a, b, x[i+10], 17, -42063); - b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); - a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); - d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); - c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); - b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); - - a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); - d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); - c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); - b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); - a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); - d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); - c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); - b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); - a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); - d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); - c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); - b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); - a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); - d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); - c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); - b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); - - a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); - d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); - c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); - b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); - a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); - d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); - c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); - b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); - a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); - d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); - c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); - b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); - a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); - d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); - c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); - b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); - - a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); - d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); - c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); - b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); - a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); - d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); - c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); - b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); - a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); - d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); - c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); - b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); - a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); - d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); - c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); - b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); - - a = safe_add(a, olda); - b = safe_add(b, oldb); - c = safe_add(c, oldc); - d = safe_add(d, oldd); - } - return Array(a, b, c, d); - -} - -/* - * These functions implement the four basic operations the algorithm uses. - */ -function md5_cmn(q, a, b, x, s, t) -{ - return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); -} -function md5_ff(a, b, c, d, x, s, t) -{ - return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); -} -function md5_gg(a, b, c, d, x, s, t) -{ - return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); -} -function md5_hh(a, b, c, d, x, s, t) -{ - return md5_cmn(b ^ c ^ d, a, b, x, s, t); -} -function md5_ii(a, b, c, d, x, s, t) -{ - return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); -} - -/* - * Calculate the HMAC-MD5, of a key and some data - */ -function core_hmac_md5(key, data) -{ - var bkey = str2binl(key); - if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); - - var ipad = Array(16), opad = Array(16); - for(var i = 0; i < 16; i++) - { - ipad[i] = bkey[i] ^ 0x36363636; - opad[i] = bkey[i] ^ 0x5C5C5C5C; - } - - var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); - return core_md5(opad.concat(hash), 512 + 128); -} - -/* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ -function safe_add(x, y) -{ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} - -/* - * Bitwise rotate a 32-bit number to the left. - */ -function bit_rol(num, cnt) -{ - return (num << cnt) | (num >>> (32 - cnt)); -} - -/* - * Convert a string to an array of little-endian words - * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. - */ -function str2binl(str) -{ - var bin = Array(); - var mask = (1 << chrsz) - 1; - for(var i = 0; i < str.length * chrsz; i += chrsz) - bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); - return bin; -} - -/* - * Convert an array of little-endian words to a string - */ -function binl2str(bin) -{ - var str = ""; - var mask = (1 << chrsz) - 1; - for(var i = 0; i < bin.length * 32; i += chrsz) - str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); - return str; -} - -/* - * Convert an array of little-endian words to a hex string. - */ -function binl2hex(binarray) -{ - var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; - var str = ""; - for(var i = 0; i < binarray.length * 4; i++) - { - str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + - hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); - } - return str; -} - -/* - * Convert an array of little-endian words to a base-64 string - */ -function binl2b64(binarray) -{ - var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - var str = ""; - for(var i = 0; i < binarray.length * 4; i += 3) - { - var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) - | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) - | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); - for(var j = 0; j < 4; j++) - { - if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; - else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); - } - } - return str; -} +/* + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} +function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} +function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} +function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } +function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } +function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } + +/* + * Perform a simple self-test to see if the VM is working + */ +function md5_vm_test() +{ + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; +} + +/* + * Calculate the MD5 of an array of little-endian words, and a bit length + */ +function core_md5(x, len) +{ + /* append padding */ + x[len >> 5] |= 0x80 << ((len) % 32); + x[(((len + 64) >>> 9) << 4) + 14] = len; + + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for(var i = 0; i < x.length; i += 16) + { + var olda = a; + var oldb = b; + var oldc = c; + var oldd = d; + + a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); + d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); + d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); + d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i+10], 17, -42063); + b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); + d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); + + a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); + d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); + c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); + a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); + d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); + c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); + d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); + c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); + d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); + c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); + + a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); + d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); + d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); + d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); + c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); + d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); + + a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); + d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); + d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); + d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); + d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return Array(a, b, c, d); + +} + +/* + * These functions implement the four basic operations the algorithm uses. + */ +function md5_cmn(q, a, b, x, s, t) +{ + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); +} +function md5_ff(a, b, c, d, x, s, t) +{ + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); +} +function md5_gg(a, b, c, d, x, s, t) +{ + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); +} +function md5_hh(a, b, c, d, x, s, t) +{ + return md5_cmn(b ^ c ^ d, a, b, x, s, t); +} +function md5_ii(a, b, c, d, x, s, t) +{ + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); +} + +/* + * Calculate the HMAC-MD5, of a key and some data + */ +function core_hmac_md5(key, data) +{ + var bkey = str2binl(key); + if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); + + var ipad = Array(16), opad = Array(16); + for(var i = 0; i < 16; i++) + { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); + return core_md5(opad.concat(hash), 512 + 128); +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safe_add(x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function bit_rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * Convert a string to an array of little-endian words + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. + */ +function str2binl(str) +{ + var bin = Array(); + var mask = (1 << chrsz) - 1; + for(var i = 0; i < str.length * chrsz; i += chrsz) + bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); + return bin; +} + +/* + * Convert an array of little-endian words to a string + */ +function binl2str(bin) +{ + var str = ""; + var mask = (1 << chrsz) - 1; + for(var i = 0; i < bin.length * 32; i += chrsz) + str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); + return str; +} + +/* + * Convert an array of little-endian words to a hex string. + */ +function binl2hex(binarray) +{ + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i++) + { + str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); + } + return str; +} + +/* + * Convert an array of little-endian words to a base-64 string + */ +function binl2b64(binarray) +{ + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i += 3) + { + var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) + | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) + | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); + for(var j = 0; j < 4; j++) + { + if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; + else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); + } + } + return str; +}
"]; [res appendString:[NSString stringWithFormat:@"%@",status,file,fileName,txt]]; @@ -280,8 +277,8 @@ BOOL inDiff=FALSE; BOOL inBlock=FALSE; - int l_int,l_line,l_end; - int r_int,r_line,r_end; + int l_line,l_end; + int r_line,r_end; int i; for (i=0; i<[lines count]; i++) { line=[lines objectAtIndex:i]; @@ -297,12 +294,12 @@ NSArray *pos_l=[[pos objectAtIndex:0] componentsSeparatedByString:@","]; NSArray *pos_r=[[pos objectAtIndex:1] componentsSeparatedByString:@","]; - l_end=l_line=l_int=abs([[pos_l objectAtIndex:0]integerValue]); + l_end=l_line=abs([[pos_l objectAtIndex:0]integerValue]); if ([pos_l count]>1) { l_end=l_line+[[pos_l objectAtIndex:1]integerValue]; } - r_end=r_line=r_int=[[pos_r objectAtIndex:0]integerValue]; + r_end=r_line=[[pos_r objectAtIndex:0]integerValue]; if ([pos_r count]>1) { r_end=r_line+[[pos_r objectAtIndex:1]integerValue]; } @@ -331,17 +328,19 @@ }else if(inDiff){ [res appendString:[NSString stringWithFormat:@"

%@

",line]]; if([self isBinaryFile:line]){ - NSLog(@"line='%@'",line); [res appendString:@"
%@
%@