From 9e140f1a7dc59aab3e5bbd5c51fd1aebc634c142 Mon Sep 17 00:00:00 2001 From: Robert Quattlebaum Date: Sat, 7 May 2011 11:08:27 -0700 Subject: [PATCH 01/63] Report an error when an attempt to open a repo throws something. --- PBGitRepository.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PBGitRepository.m b/PBGitRepository.m index 41bc6f0..8f0f92c 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -118,6 +118,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; //this works much better. - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError { + @try { if (![PBGitBinary path]) { if (outError) { @@ -153,6 +154,14 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [self setFileURL:gitDirURL]; [self setup]; return YES; + } @catch(id x) { + if (outError) { + NSDictionary* userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"An error occured while trying to open %@.\n%@", [self fileURL],x] + forKey:NSLocalizedRecoverySuggestionErrorKey]; + *outError = [NSError errorWithDomain:PBGitRepositoryErrorDomain code:0 userInfo:userInfo]; + } + return NO; + } } - (void) setup From f2fc162350d34c916714bf28be06d15524cfccdf Mon Sep 17 00:00:00 2001 From: Robert Quattlebaum Date: Sat, 7 May 2011 11:10:54 -0700 Subject: [PATCH 02/63] Make reloadRefs realize when something has gone horribly wrong. --- PBGitRepository.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PBGitRepository.m b/PBGitRepository.m index 8f0f92c..69d8405 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -280,6 +280,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; else sha = [PBGitSHA shaWithString:[components objectAtIndex:2]]; + if(!sha) { + NSLog(@"sha was nil...? ref=%@, components=%@",ref,components); + return; + } + NSMutableArray* curRefs; if ( (curRefs = [refs objectForKey:sha]) != nil ) [curRefs addObject:ref]; @@ -299,6 +304,13 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSString *output = [self outputForArguments:arguments]; NSArray *lines = [output componentsSeparatedByString:@"\n"]; + if([output hasPrefix:@"fatal: "]) { + NSLog(@"Unable to read refs!"); + NSLog(@"arguments=%@",arguments); + NSLog(@"output=%@",output); + @throw output; + } + for (NSString *line in lines) { // If its an empty line, skip it (e.g. with empty repositories) if ([line length] == 0) From 12bb9623a477a5ae7b81bce96015b202fd3efa5c Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Mon, 9 May 2011 22:18:17 -0700 Subject: [PATCH 03/63] NULL-safe escapeHTML: --- GLFileView.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GLFileView.m b/GLFileView.m index 6d4e7e5..92baab9 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -242,6 +242,8 @@ + (NSString *) escapeHTML:(NSString *)txt { + if (txt == nil) + return txt; NSMutableString *newTxt = [NSMutableString stringWithString:txt]; [newTxt replaceOccurrencesOfString:@"&" withString:@"&" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; [newTxt replaceOccurrencesOfString:@"<" withString:@"<" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; From e546078dd96a55213ffe9883556778c499bdabae Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Mon, 9 May 2011 22:32:13 -0700 Subject: [PATCH 04/63] Fixed issue with the initial commit by adding --root in diff-tree arguments. --- PBWebHistoryController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index a870c30..d6ea41c 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -107,11 +107,11 @@ NSMutableDictionary *stats=[self parseStats:details]; // File list - NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"-r", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", [currentSha string], nil]]; NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--cc", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", [currentSha string], nil]]; NSString *diffs=[GLFileView parseDiff:d]; NSString *html=[NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; From 1f735799933afb4cc5f4011854cecbf65516c5da Mon Sep 17 00:00:00 2001 From: Andrew Ryan Date: Tue, 10 May 2011 13:23:26 -0400 Subject: [PATCH 05/63] Don't crash with multiline gitconfig values. Use `git config -l -z` to get configs. --- PBGitConfig.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/PBGitConfig.m b/PBGitConfig.m index 93e38d6..36cb18d 100644 --- a/PBGitConfig.m +++ b/PBGitConfig.m @@ -99,19 +99,20 @@ NSArray* arguments; if (inDir == nil) { - arguments = [NSArray arrayWithObjects:@"config", @"--global", @"-l", nil]; + arguments = [NSArray arrayWithObjects:@"config", @"--global", @"-l", @"-z", nil]; } else { - arguments = [NSArray arrayWithObjects:@"config", @"-l", nil]; + arguments = [NSArray arrayWithObjects:@"config", @"-l", @"-z", nil]; } int ret = 1; NSString* output = [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:arguments inDir:inDir retValue:&ret]; NSMutableDictionary *result = [NSMutableDictionary dictionary]; if (ret==0) { - NSArray *lines = [output componentsSeparatedByString:@"\n"]; - + NSArray *lines = [output componentsSeparatedByString:@"\0"]; + for (NSString* line in lines) { - NSRange equalsPos = [line rangeOfString:@"="]; + if([line length] == 0) continue; + NSRange equalsPos = [line rangeOfString:@"\n"]; NSString* key = [line substringToIndex:equalsPos.location]; NSString* value = [line substringFromIndex:equalsPos.location+1]; [result setObject:value forKey:key]; From b0090ce0048534dc503f35af6c27aab712ed2a2d Mon Sep 17 00:00:00 2001 From: David Catmull Date: Mon, 9 May 2011 08:03:48 -0600 Subject: [PATCH 06/63] help text member --- PBGitSidebarController.m | 5 +++++ PBSourceViewItem.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index dad7de1..930a47c 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -342,6 +342,11 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; [cell setImage:[item icon]]; } +- (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation +{ + return [item helpText]; +} + - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item { return ![item isGroupItem]; diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index 1547fd6..ec3bd4d 100644 --- a/PBSourceViewItem.h +++ b/PBSourceViewItem.h @@ -14,7 +14,7 @@ @interface PBSourceViewItem : NSObject { NSMutableArray *children; - NSString *title; + NSString *title, *helpText; PBGitRevSpecifier *revSpecifier; PBSourceViewItem *parent; @@ -43,6 +43,7 @@ - (PBGitRef *) ref; @property(retain) NSString *title; +@property(retain) NSString *helpText; @property(readonly) NSMutableArray *children; @property(assign) BOOL isGroupItem, isUncollapsible; @property(retain) PBGitRevSpecifier *revSpecifier; From 104681c6c04e21030389b461f28e9f316322525e Mon Sep 17 00:00:00 2001 From: Victor Jalencas Date: Fri, 13 May 2011 07:44:01 -0700 Subject: [PATCH 07/63] =?UTF-8?q?Allow=20the=20project=20to=20be=20built?= =?UTF-8?q?=20in=20directories=20with=20spaces=20in=20the=20path=20name=20?= =?UTF-8?q?(such=20as=20an=20AFP=20share=20mounted=20as=20/Network/Servers?= =?UTF-8?q?/servername/Volumes/Macintosh=20HD/Networkusers/username/?= =?UTF-8?q?=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GitX.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index eea9e05..766c971 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -1337,7 +1337,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Build the scripting bridge header GitX.h if the GitX.sdef file changes\nsdef $TARGET_BUILD_DIR/GitX.app | sdp -fh --basename GitX"; + shellScript = "# Build the scripting bridge header GitX.h if the GitX.sdef file changes\nsdef \"$TARGET_BUILD_DIR/GitX.app\" | sdp -fh --basename GitX"; }; F56439F60F792B2100A579C2 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; From 6ae5d0702a3e9c7edf3d934e7c49de7fbb4c7016 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 13 May 2011 17:29:52 -0600 Subject: [PATCH 08/63] pop up the action menu immediately on click --- PBSourceViewCell.m | 79 ++++++---------------------------------------- 1 file changed, 9 insertions(+), 70 deletions(-) diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index 2c9fd5a..f50dd7c 100644 --- a/PBSourceViewCell.m +++ b/PBSourceViewCell.m @@ -12,6 +12,8 @@ @interface PBSourceViewCell() - (NSRect)infoButtonRectForBounds:(NSRect)bounds; +- (void)mouseEntered:(NSEvent *)event; +- (void)mouseExited:(NSEvent *)event; @end @implementation PBSourceViewCell @@ -91,91 +93,28 @@ } } - -//- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView { -// if (showsActionButton) { -// NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; -// // -// // NSRect titleRect = [self titleRectForBounds:cellFrame]; -// // if (NSMouseInRect(point, titleRect, [controlView isFlipped])) { -// // return NSCellHitContentArea | NSCellHitEditableTextArea; -// // } -// // -// // NSRect imageRect = [self imageRectForBounds:cellFrame]; -// // if (NSMouseInRect(point, imageRect, [controlView isFlipped])) { -// // return NSCellHitContentArea; -// // } -// // -// // // Did we hit the sub title? -// // NSAttributedString *attributedSubTitle = [self attributedSubTitle]; -// // if ([attributedSubTitle length] > 0) { -// // NSRect attributedSubTitleRect = [self rectForSubTitleBasedOnTitleRect:titleRect inBounds:cellFrame]; -// // if (NSMouseInRect(point, attributedSubTitleRect, [controlView isFlipped])) { -// // // Notice that this text isn't an editable area. Clicking on it won't begin an editing session. -// // return NSCellHitContentArea; -// // } -// // } -// -// // How about the info button? -// NSRect infoButtonRect = [self infoButtonRectForBounds:cellFrame]; -// if (NSMouseInRect(point, infoButtonRect, [controlView isFlipped])) { -// return NSCellHitContentArea | NSCellHitTrackableArea; -// } -// } -// -// return [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; -//} - -//+ (BOOL)prefersTrackingUntilMouseUp { -// // NSCell returns NO for this by default. If you want to have trackMouse:inRect:ofView:untilMouseUp: always track until the mouse is up, then you MUST return YES. Otherwise, strange things will happen. -// return YES; -//} - // Mouse tracking -- the only part we want to track is the "info" button - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag { -// [self setControlView:controlView]; -// - NSRect infoButtonRect = [self infoButtonRectForBounds:cellFrame]; - if ([theEvent type] != NSLeftMouseUp) { - // This is VERY simple event tracking. We simply check to see if the mouse is in the "i" button or not and dispatch entered/exited mouse events - NSPoint point = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; - BOOL mouseInButton = NSMouseInRect(point, infoButtonRect, [controlView isFlipped]); - if (iMouseDownInInfoButton != mouseInButton) { - iMouseDownInInfoButton = mouseInButton; - [controlView setNeedsDisplayInRect:cellFrame]; - } - if ([theEvent type] == NSMouseEntered || [theEvent type] == NSMouseExited) { - [NSApp sendEvent:theEvent]; - } - // Note that we process mouse entered and exited events and dispatch them to properly handle updates - theEvent = [[controlView window] nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)]; - } - - // Another way of implementing the above code would be to keep an NSButtonCell as an ivar, and simply call trackMouse:inRect:ofView:untilMouseUp: on it, if the tracking area was inside of it. - NSPoint locationOfTouch = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; BOOL mouseInButton = NSMouseInRect(locationOfTouch, [self infoButtonRectForBounds:cellFrame], [controlView isFlipped]); if (mouseInButton) { + [self mouseEntered:theEvent]; // show menu NSMenu *menu = [self menuForEvent:theEvent inRect:cellFrame ofView:controlView]; if (menu){ [NSMenu popUpContextMenu:menu withEvent:theEvent forView:controlView]; + return YES; } } - if (iMouseDownInInfoButton) { - // Send the action, and redisplay - iMouseDownInInfoButton = NO; - [controlView setNeedsDisplayInRect:cellFrame]; - } + if (iMouseDownInInfoButton) { + // Send the action, and redisplay + iMouseDownInInfoButton = NO; + [controlView setNeedsDisplayInRect:cellFrame]; + } return [super trackMouse:theEvent inRect:cellFrame ofView:controlView untilMouseUp:flag]; - - -// -// // We return YES since the mouse was released while we were tracking. Not returning YES when you processed the mouse up is an easy way to introduce bugs! -// return YES; } From 43e3d46b1376129ec6e517d39e136d4aa83fdf8b Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sat, 14 May 2011 10:42:30 -0600 Subject: [PATCH 09/63] helpTextForRef --- PBGitRepository.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/PBGitRepository.m b/PBGitRepository.m index 41bc6f0..5dcb9dc 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -278,6 +278,32 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha]; } +// Extracts the text that should be shown in a help tag +- (NSString*) helpTextForRef:(PBGitRef*)ref +{ + NSString *output = nil; + NSString *name = [ref shortName]; + NSArray *arguments = nil; + + if ([ref isRemote]) { + arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", name, nil]; + output = [self outputForArguments:arguments]; + + NSArray *remoteLines = [output componentsSeparatedByString:@"\n"]; + + // Second and third lines have Fetch and Push URLs + return [[remoteLines subarrayWithRange:NSMakeRange(1,1)] componentsJoinedByString:@"\n"]; + } + else if ([ref isTag]) { + arguments = [NSArray arrayWithObjects:@"tag", @"-ln", name, nil]; + output = [self outputForArguments:arguments]; + if (![output hasPrefix:name]) + return nil; + return [[output substringFromIndex:[name length]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + } + return nil; +} + - (void) reloadRefs { _headRef = nil; From 1d24c1dff374c332bbc1a5e3112f7c057c4fd7a4 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sat, 14 May 2011 10:53:42 -0600 Subject: [PATCH 10/63] hook up helpText; works with tags --- PBGitRepository.m | 1 + PBGitRevSpecifier.h | 2 ++ PBGitRevSpecifier.m | 2 +- PBGitSidebarController.m | 2 +- PBSourceViewItem.h | 3 +-- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index 5dcb9dc..2e1f9e6 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -326,6 +326,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]]; PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef]; + [revSpec setHelpText:[self helpTextForRef:newRef]]; [self addBranch:revSpec]; [self addRef:newRef fromParameters:components]; [oldBranches removeObject:revSpec]; diff --git a/PBGitRevSpecifier.h b/PBGitRevSpecifier.h index 32e96c4..7356274 100644 --- a/PBGitRevSpecifier.h +++ b/PBGitRevSpecifier.h @@ -11,6 +11,7 @@ @interface PBGitRevSpecifier : NSObject { NSString *description; + NSString *helpText; NSArray *parameters; NSURL *workingDirectory; BOOL isSimpleRef; @@ -36,6 +37,7 @@ + (PBGitRevSpecifier *)localBranchesRevSpec; @property(retain) NSString *description; +@property(retain) NSString *helpText; @property(readonly) NSArray *parameters; @property(retain) NSURL *workingDirectory; @property(readonly) BOOL isSimpleRef; diff --git a/PBGitRevSpecifier.m b/PBGitRevSpecifier.m index 1adc9ed..f4c5e38 100644 --- a/PBGitRevSpecifier.m +++ b/PBGitRevSpecifier.m @@ -11,7 +11,7 @@ @implementation PBGitRevSpecifier -@synthesize parameters, description, workingDirectory; +@synthesize parameters, description, helpText, workingDirectory; @synthesize isSimpleRef; @synthesize behind,ahead; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 930a47c..c2d04f4 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -344,7 +344,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; - (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation { - return [item helpText]; + return [[item revSpecifier] helpText]; } - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index ec3bd4d..1547fd6 100644 --- a/PBSourceViewItem.h +++ b/PBSourceViewItem.h @@ -14,7 +14,7 @@ @interface PBSourceViewItem : NSObject { NSMutableArray *children; - NSString *title, *helpText; + NSString *title; PBGitRevSpecifier *revSpecifier; PBSourceViewItem *parent; @@ -43,7 +43,6 @@ - (PBGitRef *) ref; @property(retain) NSString *title; -@property(retain) NSString *helpText; @property(readonly) NSMutableArray *children; @property(assign) BOOL isGroupItem, isUncollapsible; @property(retain) PBGitRevSpecifier *revSpecifier; From 7806e649903bc68fe30edf53d183a3c41e439a47 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sat, 14 May 2011 23:16:57 -0600 Subject: [PATCH 11/63] help tags for remotes now work --- PBGitRepository.h | 1 + PBGitRepository.m | 31 ++++++++++++++++++++----------- PBGitSVRemoteItem.h | 2 ++ PBGitSVRemoteItem.m | 1 + PBGitSidebarController.h | 6 +++--- PBGitSidebarController.m | 15 ++++++++++++++- PBSourceViewItem.h | 1 + PBSourceViewItem.m | 5 +++++ 8 files changed, 47 insertions(+), 15 deletions(-) diff --git a/PBGitRepository.h b/PBGitRepository.h index fe5369d..e8bf409 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -127,6 +127,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (BOOL) hasRemotes; - (PBGitRef *) remoteRefForBranch:(PBGitRef *)branch error:(NSError **)error; - (NSString *) infoForRemote:(NSString *)remoteName; +- (NSArray*) URLsForRemote:(NSString*)remoteName; - (void) readCurrentBranch; - (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev; diff --git a/PBGitRepository.m b/PBGitRepository.m index 2e1f9e6..275bbf8 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -278,23 +278,32 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha]; } -// Extracts the text that should be shown in a help tag +// Returns the remote's fetch and pull URLs as an array of two strings. +- (NSArray*) URLsForRemote:(NSString*)remoteName +{ + NSArray *arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", remoteName, nil]; + NSString *output = [self outputForArguments:arguments]; + + NSArray *remoteLines = [output componentsSeparatedByString:@"\n"]; + NSString *fetchURL = [remoteLines objectAtIndex:1]; + NSString *pushURL = [remoteLines objectAtIndex:2]; + + if ([fetchURL hasPrefix:@" Fetch URL: "] && [pushURL hasPrefix:@" Push URL: "]) + return [NSArray arrayWithObjects: + [fetchURL substringFromIndex:13], + [pushURL substringFromIndex:13], + nil]; + return nil; +} + +// Extracts the text that should be shown in a help tag. - (NSString*) helpTextForRef:(PBGitRef*)ref { NSString *output = nil; NSString *name = [ref shortName]; NSArray *arguments = nil; - if ([ref isRemote]) { - arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", name, nil]; - output = [self outputForArguments:arguments]; - - NSArray *remoteLines = [output componentsSeparatedByString:@"\n"]; - - // Second and third lines have Fetch and Push URLs - return [[remoteLines subarrayWithRange:NSMakeRange(1,1)] componentsJoinedByString:@"\n"]; - } - else if ([ref isTag]) { + if ([ref isTag]) { arguments = [NSArray arrayWithObjects:@"tag", @"-ln", name, nil]; output = [self outputForArguments:arguments]; if (![output hasPrefix:name]) diff --git a/PBGitSVRemoteItem.h b/PBGitSVRemoteItem.h index 8f27532..bbae557 100644 --- a/PBGitSVRemoteItem.h +++ b/PBGitSVRemoteItem.h @@ -12,9 +12,11 @@ @interface PBGitSVRemoteItem : PBSourceViewItem { BOOL alert; + NSString *helpText; } @property (assign) BOOL alert; +@property (retain) NSString *helpText; + (id)remoteItemWithTitle:(NSString *)title; diff --git a/PBGitSVRemoteItem.m b/PBGitSVRemoteItem.m index 0947cfd..7bf1bcb 100644 --- a/PBGitSVRemoteItem.m +++ b/PBGitSVRemoteItem.m @@ -13,6 +13,7 @@ @implementation PBGitSVRemoteItem @synthesize alert; +@synthesize helpText; + (id)remoteItemWithTitle:(NSString *)title { diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index 623c816..c6ff678 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -20,9 +20,9 @@ IBOutlet NSPopUpButton *actionButton; IBOutlet NSSegmentedControl *remoteControls; - IBOutlet NSButton* svnFetchButton; - IBOutlet NSButton* svnRebaseButton; - IBOutlet NSButton* svnDcommitButton; + IBOutlet NSButton* svnFetchButton; + IBOutlet NSButton* svnRebaseButton; + IBOutlet NSButton* svnDcommitButton; NSMutableArray *items; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index c2d04f4..276fa75 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -344,7 +344,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; - (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation { - return [[item revSpecifier] helpText]; + return [item helpText]; } - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item @@ -365,6 +365,17 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; return ![item isUncollapsible]; } +- (NSString*) helpTextForRemoteURLs:(NSArray*)urls +{ + NSString *fetchURL = [urls objectAtIndex:0]; + NSString *pushURL = [urls objectAtIndex:1]; + + if ([fetchURL isEqual:pushURL]) + return fetchURL; + else // Down triangle for fetch, up triangle for push + return [NSString stringWithFormat:@"\u25bc %@\n\u25b2", fetchURL, pushURL]; +} + - (void)populateList { PBSourceViewItem *project = [PBSourceViewItem groupItemWithTitle:[repository projectName]]; @@ -384,6 +395,8 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; for (PBGitRevSpecifier *rev in repository.branches) [self addRevSpec:rev]; + for (PBGitSVRemoteItem *remote in remotes.children) + [remote setHelpText:[self helpTextForRemoteURLs:[[self repository] URLsForRemote:[remote title]]]]; [items addObject:project]; [items addObject:branches]; diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index 1547fd6..1199802 100644 --- a/PBSourceViewItem.h +++ b/PBSourceViewItem.h @@ -30,6 +30,7 @@ + (id)itemWithTitle:(NSString *)title; - (NSString *)badge; +- (NSString *)helpText; - (void)addChild:(PBSourceViewItem *)child; - (void)removeChild:(PBSourceViewItem *)child; diff --git a/PBSourceViewItem.m b/PBSourceViewItem.m index 8c810c0..530ece8 100644 --- a/PBSourceViewItem.m +++ b/PBSourceViewItem.m @@ -128,6 +128,11 @@ return [[revSpecifier description] lastPathComponent]; } +- (NSString *) helpText +{ + return [revSpecifier helpText]; +} + - (NSString *) stringValue { return self.title; From 4432997fb10828faee81a748d7f8a4e11d87d9e5 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 18 May 2011 17:21:36 +0200 Subject: [PATCH 12/63] [GH-15] disappearing history --- PBGitRevList.mm | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 58992bf..6da2424 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -102,11 +102,11 @@ using namespace std; std::map encodingMap; NSThread *currentThread = [NSThread currentThread]; - NSString *formatString = @"--pretty=format:%H\01%e\01%aN\01%cN\01%s\01%P\01%at"; + NSString *formatString = @"--pretty=format:%H\01%e\01%aN\01%cN\01%P\01%at\01%s"; BOOL showSign = [rev hasLeftRight]; if (showSign) - formatString = [formatString stringByAppendingString:@"\01%m"]; + formatString = [@"%m\01" stringByAppendingString:formatString]; NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--topo-order", @"--children", formatString, nil]; @@ -129,6 +129,16 @@ using namespace std; if ([currentThread isCancelled]) break; + char c; + char sign; + if (showSign) + { + stream >> sign; + stream >> c; // Remove separator + if (sign != '>' && sign != '<' && sign != '^' && sign != '-') + DLog(@"Error loading commits: sign not correct"); + } + string sha; if (!getline(stream, sha, '\1')) break; @@ -151,15 +161,15 @@ using namespace std; git_oid_mkstr(&oid, sha.c_str()); PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:[PBGitSHA shaWithOID:oid]]; + if (showSign) + [newCommit setSign: sign]; + string author; getline(stream, author, '\1'); string committer; getline(stream, committer, '\1'); - string subject; - getline(stream, subject, '\1'); - string parentString; getline(stream, parentString, '\1'); if (parentString.size() != 0) @@ -180,26 +190,14 @@ using namespace std; int time; stream >> time; + string subject; + getline(stream, subject, '\0'); + [newCommit setSubject:[NSString stringWithCString:subject.c_str() encoding:encoding]]; [newCommit setAuthor:[NSString stringWithCString:author.c_str() encoding:encoding]]; [newCommit setCommitter:[NSString stringWithCString:committer.c_str() encoding:encoding]]; [newCommit setTimestamp:time]; - if (showSign) - { - char c; - stream >> c; // Remove separator - stream >> c; - if (c != '>' && c != '<' && c != '^' && c != '-') - DLog(@"Error loading commits: sign not correct"); - [newCommit setSign: c]; - } - - char c; - stream >> c; - if (c != '\0') - cout << "Error" << endl; - [revisions addObject: newCommit]; if (isGraphing) [g decorateCommit:newCommit]; From 2f828bb16583ac425e79e71006d09716b434cc61 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 18 May 2011 23:45:35 +0200 Subject: [PATCH 13/63] Correct new repos history. --- PBGitRevList.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 6da2424..10dd655 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -158,7 +158,9 @@ using namespace std; } git_oid oid; - git_oid_mkstr(&oid, sha.c_str()); + if(git_oid_mkstr(&oid, sha.c_str())!=GIT_SUCCESS) + break; + PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:[PBGitSHA shaWithOID:oid]]; if (showSign) From 94efa431a6f13f421f651c82ede8117b594885f0 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 19 May 2011 00:01:49 +0200 Subject: [PATCH 14/63] conditionalize usage of 10.6-only protocols David Catmull (Uncommon) Uncommon/gitx@e5b603f188760d341ca5c578ee9a42ebcc46ba4b Conflicts: DBPrefsWindowController.h PBGitHistoryController.h PBGitSidebarController.h PBGitWindowController.h --- DBPrefsWindowController.h | 2 +- GitX_Prefix.pch | 13 +++++++++++++ PBGitHistoryController.h | 2 +- PBGitSidebarController.h | 2 +- PBGitWindowController.h | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DBPrefsWindowController.h b/DBPrefsWindowController.h index 63b7855..63a80d0 100644 --- a/DBPrefsWindowController.h +++ b/DBPrefsWindowController.h @@ -42,7 +42,7 @@ #import -@interface DBPrefsWindowController : NSWindowController /**/{ +@interface DBPrefsWindowController : NSWindowController PROTOCOL_10_6(NSAnimationDelegate,NSToolbarDelegate){ NSMutableArray *toolbarIdentifiers; NSMutableDictionary *toolbarViews; NSMutableDictionary *toolbarItems; diff --git a/GitX_Prefix.pch b/GitX_Prefix.pch index f1ce03e..0af9ac2 100644 --- a/GitX_Prefix.pch +++ b/GitX_Prefix.pch @@ -17,3 +17,16 @@ #ifndef ALog #define ALog(...) DLog(__VA_ARGS__) #endif + +// In 10.6, some NSObject categories (like NSWindowDelegate) were changed to +// protocols. Thus to avoid warnings we need to add protocol specifiers, but +// only when compiling for 10.6+. +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#define PROTOCOL_10_6(...) <__VA_ARGS__> +#else +#define PROTOCOL_10_6(...) +#endif diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index f9cf468..a09bc64 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -22,7 +22,7 @@ @class PBHistorySearchController; -@interface PBGitHistoryController : PBViewController /**/{ +@interface PBGitHistoryController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate){ IBOutlet PBRefController *refController; IBOutlet NSSearchField *searchField; IBOutlet NSArrayController* commitController; diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index 623c816..64fd606 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -13,7 +13,7 @@ @class PBGitHistoryController; @class PBGitCommitController; -@interface PBGitSidebarController : PBViewController /**/{ +@interface PBGitSidebarController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate, NSMenuDelegate){ IBOutlet NSWindow *window; IBOutlet NSOutlineView *sourceView; IBOutlet NSView *sourceListControlsView; diff --git a/PBGitWindowController.h b/PBGitWindowController.h index c844bf6..a3bb3cb 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -14,7 +14,7 @@ @class PBViewController, PBGitSidebarController, PBGitCommitController; -@interface PBGitWindowController : NSWindowController /**/{ +@interface PBGitWindowController : NSWindowController PROTOCOL_10_6(NSWindowDelegate){ __weak PBGitRepository* repository; PBViewController *contentController; From 2a2761d354a443132d9396114747bafac946fc84 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Wed, 18 May 2011 13:04:48 +0200 Subject: [PATCH 15/63] Updates submodule to point to GitHub repository of LibGit2 Updated submodule to libGit 0.12 --- .gitmodules | 2 +- libgit2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 6794840..2be1c54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "libgit2"] path = libgit2 - url = git://repo.or.cz/libgit2.git \ No newline at end of file + url = git://github.com/libgit2/libgit2.git \ No newline at end of file diff --git a/libgit2 b/libgit2 index 998a7bf..4077454 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 998a7bf824c5faca0f9766c9b89bb73ec1315272 +Subproject commit 40774549e14e2d9f24b9271173d58b44f82d5254 From 6d8982ab4b4436c8aadf5f6e89a15a4eaf346133 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Wed, 18 May 2011 14:06:55 +0200 Subject: [PATCH 16/63] Build with WAF outside of source tree. Update headers and search paths with new build logic. --- GitX.xcodeproj/project.pbxproj | 16 +++++++++------- PBGitGrapher.mm | 2 +- PBGitLane.h | 2 +- PBGitSHA.h | 2 +- PBGitSHA.m | 2 +- build_libgit2.sh | 27 ++++++++++++++++++--------- libgit2 | 2 +- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 766c971..d177e2e 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -503,7 +503,7 @@ F5B721C30E05CF7E00AF29DC /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = ""; }; F5C007730E731B48007B84B2 /* PBGitRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRef.h; sourceTree = ""; }; F5C007740E731B48007B84B2 /* PBGitRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRef.m; sourceTree = ""; }; - F5C580E40EDA250900995434 /* libgit2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgit2.a; path = libgit2/libgit2.a; sourceTree = ""; }; + F5C580E40EDA250900995434 /* libgit2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; }; F5C6F68B0E65FF9300478D97 /* PBGitLane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitLane.h; sourceTree = ""; }; F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBGitLane.mm; sourceTree = ""; }; F5D2DC850EA401A80034AD24 /* PBGitConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitConfig.h; sourceTree = ""; }; @@ -1616,13 +1616,14 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GitX_Prefix.pch; - HEADER_SEARCH_PATHS = libgit2/src; + HEADER_SEARCH_PATHS = libgit2/include; INFOPLIST_FILE = Info.plist; INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision; INFOPLIST_PREPROCESS = YES; INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = libgit2; + LIBRARY_SEARCH_PATHS = ""; + ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = GitX; SDKROOT = ""; WRAPPER_EXTENSION = app; @@ -1643,13 +1644,13 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GitX_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; - HEADER_SEARCH_PATHS = libgit2/src; + HEADER_SEARCH_PATHS = libgit2/include; INFOPLIST_FILE = Info.plist; INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision; INFOPLIST_PREPROCESS = YES; INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = libgit2; + LIBRARY_SEARCH_PATHS = ""; PRODUCT_NAME = GitX; SDKROOT = ""; WRAPPER_EXTENSION = app; @@ -1771,7 +1772,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = libgit2; + LIBRARY_SEARCH_PATHS = ""; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "-framework", Foundation, @@ -1795,7 +1797,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = libgit2; + LIBRARY_SEARCH_PATHS = ""; OTHER_LDFLAGS = ( "-framework", Foundation, diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index d22ba6c..47d9cfd 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -11,7 +11,7 @@ #import "PBGitLane.h" #import "PBGitGraphLine.h" #import -#import "git/oid.h" +#import using namespace std; diff --git a/PBGitLane.h b/PBGitLane.h index 94b59a2..136e5b3 100644 --- a/PBGitLane.h +++ b/PBGitLane.h @@ -6,7 +6,7 @@ // Copyright 2008 __MyCompanyName__. All rights reserved. // #import -#include "git/oid.h" +#include class PBGitLane { static int s_colorIndex; diff --git a/PBGitSHA.h b/PBGitSHA.h index f222911..15eeeb3 100644 --- a/PBGitSHA.h +++ b/PBGitSHA.h @@ -7,7 +7,7 @@ // #import -#include "git/oid.h" +#include @interface PBGitSHA : NSObject { diff --git a/PBGitSHA.m b/PBGitSHA.m index 1745133..a310040 100644 --- a/PBGitSHA.m +++ b/PBGitSHA.m @@ -7,7 +7,7 @@ // #import "PBGitSHA.h" - +#import @interface PBGitSHA () diff --git a/build_libgit2.sh b/build_libgit2.sh index 20d4c26..c5cd3d3 100755 --- a/build_libgit2.sh +++ b/build_libgit2.sh @@ -9,20 +9,29 @@ # based on: http://log.yeahrightkeller.com/post/270155578/run-script-while-cleaning-in-xcode buildAction () { - echo "Building libgit2..." + echo "Building libgit2..." if [[ -d .git ]] then - if [ "$(which git)" == "" ]; then - echo "git not found" - exit -1 - fi + if [ "$(which git)" == "" ]; then + echo "git not found" + exit -1 + fi git submodule init git submodule sync git submodule update cd libgit2 - rm -f libgit2.a - make CFLAGS="-arch i386 -arch ppc" - ranlib libgit2.a + ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure + if [ $? != 0 ]; then + echo "error: failed to waf configure" + exit -1 + fi + ./waf build-static + if [ $? != 0 ]; then + echo "error: failed to waf build-static" + exit -1 + fi + ranlib $TARGET_TEMP_DIR/static/libgit2.a + cp $TARGET_TEMP_DIR/static/libgit2.a $TARGET_BUILD_DIR else echo "error: Not a git repository." echo "error: clone GitX first so that the libgit2 submodule can be updated" @@ -33,7 +42,7 @@ buildAction () { cleanAction () { echo "Cleaning libgit2..." cd libgit2 - make clean + ./waf clean } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libgit2 b/libgit2 index 4077454..d1685ac 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 40774549e14e2d9f24b9271173d58b44f82d5254 +Subproject commit d1685ac7e91c5269cf01f6ab57c2c4705a14e6bc From b3cfd7fd0d9e5f7095e4ce89257dcd71e676ae2b Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Wed, 18 May 2011 17:40:13 +0200 Subject: [PATCH 17/63] Build fat libgit2 --- build_libgit2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_libgit2.sh b/build_libgit2.sh index c5cd3d3..dfbb003 100755 --- a/build_libgit2.sh +++ b/build_libgit2.sh @@ -20,7 +20,7 @@ buildAction () { git submodule sync git submodule update cd libgit2 - ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure + CFLAGS='-arch i386 -arch x86_64' ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure if [ $? != 0 ]; then echo "error: failed to waf configure" exit -1 From 451335acd3f55234371df54274e5fce3f544049f Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Wed, 18 May 2011 11:43:40 +0200 Subject: [PATCH 18/63] Build fat and use XCode's 32_64 arch specification style. --- GitX.xcodeproj/project.pbxproj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index d177e2e..92317c4 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -1227,6 +1227,7 @@ isa = PBXProject; buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -1604,6 +1605,7 @@ 26FC0A850875C7B200E6366F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1634,6 +1636,7 @@ 26FC0A860875C7B200E6366F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1696,6 +1699,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -1704,6 +1708,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; INSTALL_PATH = /usr/local/bin; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "-framework", Foundation, @@ -1720,6 +1725,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = dwarf; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -1744,6 +1750,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1764,6 +1771,7 @@ 913D5E4B0E55644600CECEA2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -1790,6 +1798,7 @@ 913D5E4C0E55644600CECEA2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -1814,6 +1823,7 @@ D8022B1511DFCE7F003C21F6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -1825,6 +1835,7 @@ D8022B1611DFCE7F003C21F6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -1837,6 +1848,7 @@ F56439F80F792B2100A579C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -1848,6 +1860,7 @@ F56439F90F792B2100A579C2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; From 16c4ef4ae64771d6e6a3f60afcf650e7073264f7 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Wed, 18 May 2011 18:09:12 +0200 Subject: [PATCH 19/63] Switch to own fork to have wafscript hack. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 2be1c54..6e08054 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "libgit2"] path = libgit2 - url = git://github.com/libgit2/libgit2.git \ No newline at end of file + url = git://github.com/RomainMuller/libgit2.git \ No newline at end of file From a3175617da2c08904967697bdd3ba4d3826ca5c0 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 09:29:47 +0200 Subject: [PATCH 20/63] Fix missing symbol due to relocation in libgit2. --- PBGitRevList.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 10dd655..b787e59 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -17,6 +17,8 @@ #include #include +#include + using namespace std; From 22e4f1894ffd76a3fadddecf2396ffd3ad06d813 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 19 May 2011 11:15:08 +0200 Subject: [PATCH 21/63] build_libgit2.sh bug --- build_libgit2.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_libgit2.sh b/build_libgit2.sh index dfbb003..15b92ea 100755 --- a/build_libgit2.sh +++ b/build_libgit2.sh @@ -20,7 +20,8 @@ buildAction () { git submodule sync git submodule update cd libgit2 - CFLAGS='-arch i386 -arch x86_64' ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure + CFLAGS='-arch i386 -arch x86_64' + ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure if [ $? != 0 ]; then echo "error: failed to waf configure" exit -1 From 970352c89a50dc7ff42da19c59ee6a8075bf99ec Mon Sep 17 00:00:00 2001 From: Valiev Omar Date: Thu, 19 May 2011 14:55:33 +0400 Subject: [PATCH 22/63] New Dock menu. --- English.lproj/MainMenu.xib | 2066 +++++------------------------------- 1 file changed, 270 insertions(+), 1796 deletions(-) diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 9b8ab97..c272331 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -2,17 +2,20 @@ 1050 - 10F569 - 788 - 1038.29 + 10J869 + 1306 + 1038.35 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 788 + 1306 - + YES - + NSUserDefaultsController + NSMenu + NSMenuItem + NSCustomObject YES @@ -944,6 +947,66 @@ _NSMainMenu + + + + YES + + + New… + n + 1048576 + 2147483647 + + + + + + Clone… + + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + + Open Recent + + + YES + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + ApplicationController @@ -1400,6 +1463,46 @@ 973 + + + openDocument: + + + + 984 + + + + showCloneRepository: + + + + 985 + + + + clearRecentDocuments: + + + + 986 + + + + newDocument: + + + + 987 + + + + dockMenu + + + + 988 + @@ -2123,6 +2226,57 @@ + + 974 + + + YES + + + + + + + Dock menu + + + 978 + + + YES + + + + + + 982 + + + YES + + + + + + 983 + + + + + 979 + + + + + 980 + + + + + 981 + + + @@ -2327,6 +2481,19 @@ 964.ImportedFromIB2 969.IBPluginDependency 972.IBPluginDependency + 974.IBPluginDependency + 978.IBPluginDependency + 978.ImportedFromIB2 + 979.IBPluginDependency + 979.ImportedFromIB2 + 980.IBPluginDependency + 980.ImportedFromIB2 + 981.IBPluginDependency + 982.IBEditorWindowLastContentRect + 982.IBPluginDependency + 982.ImportedFromIB2 + 983.IBPluginDependency + 983.ImportedFromIB2 YES @@ -2528,25 +2695,34 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + {{778, 673}, {143, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + YES - - YES - + YES - - YES - + - 973 + 988 @@ -2558,7 +2734,6 @@ YES YES - discussGitX: installCliTool: openPreferencesWindow: reportAProblem: @@ -2576,14 +2751,12 @@ id id id - id YES YES - discussGitX: installCliTool: openPreferencesWindow: reportAProblem: @@ -2594,10 +2767,6 @@ YES - - discussGitX: - id - installCliTool: id @@ -2662,20 +2831,11 @@ IBProjectSource - ApplicationController.h - - - - ApplicationController - NSObject - - IBUserSource - + ./Classes/ApplicationController.h FirstResponder - NSObject YES @@ -2728,79 +2888,70 @@ - NSApplication - - IBProjectSource - NSApplication+GitXScripting.h - - - - NSOutlineView - - IBProjectSource - NSOutlineViewExt.h - - - - PBCollapsibleSplitView - PBNiceSplitView - - IBProjectSource - PBCollapsibleSplitView.h - - - - PBCommitList - NSTableView - + NSDocument + YES YES - controller - searchController - webController - webView + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: YES - PBGitHistoryController - PBHistorySearchController - PBWebHistoryController - WebView + id + id + id + id + id + id - + YES YES - controller - searchController - webController - webView + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: YES - - controller - PBGitHistoryController + + printDocument: + id - - searchController - PBHistorySearchController + + revertDocumentToSaved: + id - - webController - PBWebHistoryController + + runPageLayout: + id - - webView - WebView + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id IBProjectSource - PBCommitList.h + ./Classes/NSDocument.h @@ -2844,13 +2995,11 @@ YES branchNameField errorMessageField - startRefish YES NSTextField NSTextField - id @@ -2859,7 +3008,6 @@ YES branchNameField errorMessageField - startRefish YES @@ -2871,15 +3019,11 @@ errorMessageField NSTextField - - startRefish - id - IBProjectSource - PBCreateBranchSheet.h + ./Classes/PBCreateBranchSheet.h @@ -2924,14 +3068,12 @@ errorMessageField tagMessageText tagNameField - targetRefish YES NSTextField NSTextView NSTextField - id @@ -2941,7 +3083,6 @@ errorMessageField tagMessageText tagNameField - targetRefish YES @@ -2957,15 +3098,11 @@ tagNameField NSTextField - - targetRefish - id - IBProjectSource - PBCreateTagSheet.h + ./Classes/PBCreateTagSheet.h @@ -3024,6 +3161,7 @@ cachedFilesController commitButton commitMessageView + commitSplitView indexController unstagedFilesController webController @@ -3033,6 +3171,7 @@ NSArrayController NSButton NSTextView + NSSplitView PBGitIndexController NSArrayController PBWebChangesController @@ -3045,6 +3184,7 @@ cachedFilesController commitButton commitMessageView + commitSplitView indexController unstagedFilesController webController @@ -3063,6 +3203,10 @@ commitMessageView NSTextView + + commitSplitView + NSSplitView + indexController PBGitIndexController @@ -3079,15 +3223,7 @@ IBProjectSource - PBGitCommitController.h - - - - PBGitGradientBarView - NSView - - IBProjectSource - PBGitGradientBarView.h + ./Classes/PBGitCommitController.h @@ -3101,7 +3237,6 @@ createBranch: createTag: merge: - openFilesAction: openSelectedFile: rebase: refresh: @@ -3111,9 +3246,8 @@ setDetailedView: setTreeView: showAddRemoteSheet: - showCommitsFromTree: - showInFinderAction: toggleQLPreviewPanel: + updateSearch: YES @@ -3132,8 +3266,6 @@ id id id - id - id @@ -3144,7 +3276,6 @@ createBranch: createTag: merge: - openFilesAction: openSelectedFile: rebase: refresh: @@ -3154,9 +3285,8 @@ setDetailedView: setTreeView: showAddRemoteSheet: - showCommitsFromTree: - showInFinderAction: toggleQLPreviewPanel: + updateSearch: YES @@ -3176,10 +3306,6 @@ merge: id - - openFilesAction: - id - openSelectedFile: id @@ -3216,167 +3342,19 @@ showAddRemoteSheet: id - - showCommitsFromTree: - id - - - showInFinderAction: - id - toggleQLPreviewPanel: id - - - - YES - - YES - allBranchesFilterItem - cherryPickButton - commitController - commitList - fileBrowser - historySplitView - localRemoteBranchesFilterItem - mergeButton - rebaseButton - refController - scopeBarView - searchController - searchField - selectedBranchFilterItem - treeController - upperToolbarView - webHistoryController - webView - - - YES - NSButton - NSButton - NSArrayController - PBCommitList - NSOutlineView - PBCollapsibleSplitView - NSButton - NSButton - NSButton - PBRefController - PBGitGradientBarView - PBHistorySearchController - NSSearchField - NSButton - NSTreeController - PBGitGradientBarView - PBWebHistoryController - id - - - - YES - - YES - allBranchesFilterItem - cherryPickButton - commitController - commitList - fileBrowser - historySplitView - localRemoteBranchesFilterItem - mergeButton - rebaseButton - refController - scopeBarView - searchController - searchField - selectedBranchFilterItem - treeController - upperToolbarView - webHistoryController - webView - - - YES - - allBranchesFilterItem - NSButton - - - cherryPickButton - NSButton - - - commitController - NSArrayController - - - commitList - PBCommitList - - - fileBrowser - NSOutlineView - - - historySplitView - PBCollapsibleSplitView - - - localRemoteBranchesFilterItem - NSButton - - - mergeButton - NSButton - - - rebaseButton - NSButton - - - refController - PBRefController - - - scopeBarView - PBGitGradientBarView - - - searchController - PBHistorySearchController - - - searchField - NSSearchField - - - selectedBranchFilterItem - NSButton - - - treeController - NSTreeController - - - upperToolbarView - PBGitGradientBarView - - - webHistoryController - PBWebHistoryController - - - webView + + updateSearch: id IBProjectSource - PBGitHistoryController.h + ./Classes/PBGitHistoryController.h @@ -3469,7 +3447,7 @@ IBProjectSource - PBGitIndexController.h + ./Classes/PBGitIndexController.h @@ -3479,6 +3457,7 @@ YES YES + changeLayout: cloneTo: openInTerminal: refresh: @@ -3494,12 +3473,14 @@ id id id + id YES YES + changeLayout: cloneTo: openInTerminal: refresh: @@ -3509,6 +3490,10 @@ YES + + changeLayout: + id + cloneTo: id @@ -3535,501 +3520,9 @@ - - YES - - YES - contentSplitView - finderItem - progressIndicator - sourceListControlsView - sourceSplitView - splitView - statusField - terminalItem - - - YES - NSView - NSToolbarItem - NSProgressIndicator - NSView - NSView - NSSplitView - NSTextField - NSToolbarItem - - - - YES - - YES - contentSplitView - finderItem - progressIndicator - sourceListControlsView - sourceSplitView - splitView - statusField - terminalItem - - - YES - - contentSplitView - NSView - - - finderItem - NSToolbarItem - - - progressIndicator - NSProgressIndicator - - - sourceListControlsView - NSView - - - sourceSplitView - NSView - - - splitView - NSSplitView - - - statusField - NSTextField - - - terminalItem - NSToolbarItem - - - IBProjectSource - PBGitWindowController.h - - - - PBGitWindowController - NSWindowController - - YES - - YES - openSelectedFile: - setDetailedView: - setRawView: - setTreeView: - toggleQuickView: - - - YES - id - id - id - id - id - - - - YES - - YES - openSelectedFile: - setDetailedView: - setRawView: - setTreeView: - toggleQuickView: - - - YES - - openSelectedFile: - id - - - setDetailedView: - id - - - setRawView: - id - - - setTreeView: - id - - - toggleQuickView: - id - - - - - YES - - YES - commitController - commitList - fileBrowser - treeController - - - YES - NSArrayController - NSTableView - NSOutlineView - NSTreeController - - - - YES - - YES - commitController - commitList - fileBrowser - treeController - - - YES - - commitController - NSArrayController - - - commitList - NSTableView - - - fileBrowser - NSOutlineView - - - treeController - NSTreeController - - - - - IBUserSource - - - - - PBHistorySearchController - NSObject - - YES - - YES - selectSearchMode: - stepperPressed: - updateSearch: - - - YES - id - id - id - - - - YES - - YES - selectSearchMode: - stepperPressed: - updateSearch: - - - YES - - selectSearchMode: - id - - - stepperPressed: - id - - - updateSearch: - id - - - - - YES - - YES - commitController - historyController - numberOfMatchesField - progressIndicator - searchField - stepper - - - YES - NSArrayController - PBGitHistoryController - NSTextField - NSProgressIndicator - NSSearchField - NSSegmentedControl - - - - YES - - YES - commitController - historyController - numberOfMatchesField - progressIndicator - searchField - stepper - - - YES - - commitController - NSArrayController - - - historyController - PBGitHistoryController - - - numberOfMatchesField - NSTextField - - - progressIndicator - NSProgressIndicator - - - searchField - NSSearchField - - - stepper - NSSegmentedControl - - - - - IBProjectSource - PBHistorySearchController.h - - - - PBNiceSplitView - NSSplitView - - IBProjectSource - PBNiceSplitView.h - - - - PBRefController - NSObject - - YES - - YES - checkout: - cherryPick: - copyPatch: - copySHA: - createBranch: - createTag: - diffWithHEAD: - fetchRemote: - merge: - pullRemote: - pushDefaultRemoteForRef: - pushToRemote: - pushUpdatesToRemote: - rebaseHeadBranch: - showTagInfoSheet: - - - YES - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - - - - YES - - YES - checkout: - cherryPick: - copyPatch: - copySHA: - createBranch: - createTag: - diffWithHEAD: - fetchRemote: - merge: - pullRemote: - pushDefaultRemoteForRef: - pushToRemote: - pushUpdatesToRemote: - rebaseHeadBranch: - showTagInfoSheet: - - - YES - - checkout: - PBRefMenuItem - - - cherryPick: - PBRefMenuItem - - - copyPatch: - PBRefMenuItem - - - copySHA: - PBRefMenuItem - - - createBranch: - PBRefMenuItem - - - createTag: - PBRefMenuItem - - - diffWithHEAD: - PBRefMenuItem - - - fetchRemote: - PBRefMenuItem - - - merge: - PBRefMenuItem - - - pullRemote: - PBRefMenuItem - - - pushDefaultRemoteForRef: - PBRefMenuItem - - - pushToRemote: - PBRefMenuItem - - - pushUpdatesToRemote: - PBRefMenuItem - - - rebaseHeadBranch: - PBRefMenuItem - - - showTagInfoSheet: - PBRefMenuItem - - - - - YES - - YES - branchPopUp - commitController - commitList - historyController - - - YES - NSPopUpButton - NSArrayController - PBCommitList - PBGitHistoryController - - - - YES - - YES - branchPopUp - commitController - commitList - historyController - - - YES - - branchPopUp - NSPopUpButton - - - commitController - NSArrayController - - - commitList - PBCommitList - - - historyController - PBGitHistoryController - - - - - IBProjectSource - PBRefController.h - - - - PBRefMenuItem - NSMenuItem - - refish - id - - - refish - - refish - id - - - - IBProjectSource - PBRefMenuItem.h + ./Classes/PBGitWindowController.h @@ -4037,15 +3530,7 @@ NSDocumentController IBProjectSource - PBRepositoryDocumentController.h - - - - PBRepositoryDocumentController - NSDocumentController - - IBUserSource - + ./Classes/PBRepositoryDocumentController.h @@ -4064,7 +3549,7 @@ IBProjectSource - PBViewController.h + ./Classes/PBViewController.h @@ -4118,7 +3603,7 @@ IBProjectSource - PBWebChangesController.h + ./Classes/PBWebChangesController.h @@ -4158,1035 +3643,25 @@ IBProjectSource - PBWebController.h + ./Classes/PBWebController.h - PBWebHistoryController - PBWebController - - YES - - YES - contextMenuDelegate - historyController - - - YES - id - PBGitHistoryController - + WebView + + reloadFromOrigin: + id - - YES - - YES - contextMenuDelegate - historyController - - - YES - - contextMenuDelegate - id - - - historyController - PBGitHistoryController - + + reloadFromOrigin: + + reloadFromOrigin: + id IBProjectSource - PBWebHistoryController.h - - - - - YES - - NSObject - - IBDocumentRelativeSource - ../Sparkle.framework/Versions/A/Headers/SUUpdater.h - - - - SUUpdater - NSObject - - checkForUpdates: - id - - - checkForUpdates: - - checkForUpdates: - id - - - - delegate - id - - - delegate - - delegate - id - - - - - - - YES - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - - - NSArrayController - NSObjectController - - IBFrameworkSource - AppKit.framework/Headers/NSArrayController.h - - - - NSBrowser - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSBrowser.h - - - - NSButton - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSButton.h - - - - NSCell - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSCell.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSController - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSController.h - - - - NSDocument - NSObject - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - - - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocument.h - - - - NSDocument - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentScripting.h - - - - NSDocumentController - NSObject - - YES - - YES - clearRecentDocuments: - newDocument: - openDocument: - saveAllDocuments: - - - YES - id - id - id - id - - - - YES - - YES - clearRecentDocuments: - newDocument: - openDocument: - saveAllDocuments: - - - YES - - clearRecentDocuments: - id - - - newDocument: - id - - - openDocument: - id - - - saveAllDocuments: - id - - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentController.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSManagedObjectContext - NSObject - - IBFrameworkSource - CoreData.framework/Headers/NSManagedObjectContext.h - - - - NSMatrix - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSMatrix.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSMenuItem - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSMovieView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSMovieView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CAAnimation.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CALayer.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CIImageProvider.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUAppcast.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUUpdater.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebDownload.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebEditingDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebFrameLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebJavaPlugIn.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPlugin.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPluginContainer.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPolicyDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebResourceLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebScriptObject.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebUIDelegate.h - - - - NSObjectController - NSController - - IBFrameworkSource - AppKit.framework/Headers/NSObjectController.h - - - - NSOutlineView - NSTableView - - - - NSPopUpButton - NSButton - - IBFrameworkSource - AppKit.framework/Headers/NSPopUpButton.h - - - - NSProgressIndicator - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSProgressIndicator.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSSearchField - NSTextField - - IBFrameworkSource - AppKit.framework/Headers/NSSearchField.h - - - - NSSegmentedControl - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedControl.h - - - - NSSplitView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSSplitView.h - - - - NSTableView - NSControl - - - - NSText - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSText.h - - - - NSTextField - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSTextField.h - - - - NSTextView - NSText - - IBFrameworkSource - AppKit.framework/Headers/NSTextView.h - - - - NSToolbarItem - NSObject - - - - NSTreeController - NSObjectController - - IBFrameworkSource - AppKit.framework/Headers/NSTreeController.h - - - - NSUserDefaultsController - NSController - - IBFrameworkSource - AppKit.framework/Headers/NSUserDefaultsController.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSViewController - NSResponder - - view - NSView - - - view - - view - NSView - - - - IBFrameworkSource - AppKit.framework/Headers/NSViewController.h - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSDrawer.h - - - - NSWindow - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h - - - - NSWindowController - NSResponder - - showWindow: - id - - - showWindow: - - showWindow: - id - - - - IBFrameworkSource - AppKit.framework/Headers/NSWindowController.h - - - - SUUpdater - NSObject - - checkForUpdates: - id - - - checkForUpdates: - - checkForUpdates: - id - - - - delegate - id - - - delegate - - delegate - id - - - - - - WebView - NSView - - YES - - YES - goBack: - goForward: - makeTextLarger: - makeTextSmaller: - makeTextStandardSize: - reload: - reloadFromOrigin: - stopLoading: - takeStringURLFrom: - toggleContinuousSpellChecking: - toggleSmartInsertDelete: - - - YES - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - goBack: - goForward: - makeTextLarger: - makeTextSmaller: - makeTextStandardSize: - reload: - reloadFromOrigin: - stopLoading: - takeStringURLFrom: - toggleContinuousSpellChecking: - toggleSmartInsertDelete: - - - YES - - goBack: - id - - - goForward: - id - - - makeTextLarger: - id - - - makeTextSmaller: - id - - - makeTextStandardSize: - id - - - reload: - id - - - reloadFromOrigin: - id - - - stopLoading: - id - - - takeStringURLFrom: - id - - - toggleContinuousSpellChecking: - id - - - toggleSmartInsertDelete: - id - - - - - IBFrameworkSource - WebKit.framework/Headers/WebView.h + ./Classes/WebView.h @@ -5206,7 +3681,6 @@ YES - ../GitX.xcodeproj 3 YES From 3ada98c765e0d161c1e0892b7d8824da53fe9972 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 18:09:01 +0200 Subject: [PATCH 23/63] Use of stringWithFormat in this situation is overkill. --- PBGitCommitController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 6ea4c95..75e79e6 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -170,7 +170,7 @@ { [commitMessageView setEditable:YES]; [commitMessageView setString:@""]; - [webController setStateMessage:[NSString stringWithFormat:[[notification userInfo] objectForKey:@"description"]]]; + [webController setStateMessage:[NSString stringWithString:[[notification userInfo] objectForKey:@"description"]]]; [repository reloadRefs]; } From a56f82ac2ca493ff3b3fc78d98edc1a56a6ee780 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 18:16:02 +0200 Subject: [PATCH 24/63] Ugly coupling with mis-use of delegate is ugly. --- PBFileChangesTableView.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PBFileChangesTableView.m b/PBFileChangesTableView.m index f2ea75d..c0707f0 100644 --- a/PBFileChangesTableView.m +++ b/PBFileChangesTableView.m @@ -18,7 +18,8 @@ NSPoint eventLocation = [self convertPoint: [theEvent locationInWindow] fromView: nil]; NSInteger rowIndex = [self rowAtPoint:eventLocation]; [self selectRowIndexes:[NSIndexSet indexSetWithIndex:rowIndex] byExtendingSelection:TRUE]; - return [[self delegate] menuForTable: self]; + // TODO: Fix the coupling so we don't need the cast (at least). + return [(PBGitIndexController*)[self delegate] menuForTable: self]; } return nil; From b71e1ca0f0d4f9e0c96ccd9aa66bd724262be2ca Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 18:16:17 +0200 Subject: [PATCH 25/63] Explicit cast is needed if we abuse the delegate that way. --- PBSourceViewCell.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index 2c9fd5a..1f2f809 100644 --- a/PBSourceViewCell.m +++ b/PBSourceViewCell.m @@ -33,7 +33,7 @@ NSPoint point = [self.controlView convertPoint:[event locationInWindow] fromView:nil]; NSInteger row = [view rowAtPoint:point]; - PBGitSidebarController *controller = [view delegate]; + PBGitSidebarController *controller = (PBGitSidebarController*)[view delegate]; return [controller menuForRow:row]; } From 7f281498f038366b8582df3a0b3c7d0bf5c86b38 Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 18:15:28 +0200 Subject: [PATCH 26/63] Add missing message declaration in header file. Use specific type instead of id. --- PBGitRepository.h | 1 + PBWebController.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/PBGitRepository.h b/PBGitRepository.h index fe5369d..7e4cd6f 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -88,6 +88,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (NSFileHandle*) handleForCommand:(NSString*) cmd; - (NSFileHandle*) handleForArguments:(NSArray*) args; +- (NSFileHandle*) handleInWorkDirForArguments:(NSArray *)args; - (NSFileHandle *) handleInWorkDirForArguments:(NSArray *)args; - (NSString*) outputForCommand:(NSString*) cmd; - (NSString *)outputForCommand:(NSString *)str retValue:(int *)ret; diff --git a/PBWebController.h b/PBWebController.h index 4aa30d9..4582230 100644 --- a/PBWebController.h +++ b/PBWebController.h @@ -9,6 +9,8 @@ #import #import +#import "PBGitRepository.h" + @interface PBWebController : NSObject { IBOutlet WebView* view; NSString *startFile; @@ -18,11 +20,11 @@ NSMapTable *callbacks; // For the repository access - IBOutlet id repository; + IBOutlet PBGitRepository *repository; } @property (retain) NSString *startFile; -@property (retain) id repository; +@property (retain) PBGitRepository *repository; - (WebScriptObject *) script; - (void) closeView; From c1b3658e056e8f2c40a289cc1945864c26d6548c Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Thu, 19 May 2011 18:22:02 +0200 Subject: [PATCH 27/63] Explicit cast to remove warning. --- PBWebHistoryController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index d6ea41c..a05bfe8 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -122,7 +122,7 @@ [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; #ifdef DEBUG_BUILD - NSString *dom=[[[[view mainFrame] DOMDocument] documentElement] outerHTML]; + NSString *dom=[(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; NSString *tmpFile=@"~/tmp/test2.html"; [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; #endif From ac1019d5cc53ebc32cdc88aac82a60654030d68c Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 20 May 2011 00:46:13 +0200 Subject: [PATCH 28/63] no libgit2 --- .gitmodules | 3 - GLFileView.m | 2 +- GitX.xcodeproj/project.pbxproj | 72 ----------------- PBGitCommit.h | 9 +-- PBGitCommit.m | 7 +- PBGitGrapher.mm | 13 ++- PBGitHistoryController.h | 4 +- PBGitHistoryController.m | 4 +- PBGitHistoryGrapher.m | 3 +- PBGitHistoryList.h | 3 +- PBGitHistoryList.m | 9 +-- PBGitLane.h | 26 ++---- PBGitLane.mm | 2 +- PBGitRepository.h | 14 ++-- PBGitRepository.m | 24 +++--- PBGitRevList.mm | 16 ++-- PBGitRevisionCell.m | 4 +- PBGitSHA.h | 28 ------- PBGitSHA.m | 139 --------------------------------- PBHistorySearchController.m | 2 +- PBWebHistoryController.h | 4 +- PBWebHistoryController.m | 13 ++- build_libgit2.sh | 66 ---------------- libgit2 | 1 - 24 files changed, 69 insertions(+), 399 deletions(-) delete mode 100644 .gitmodules delete mode 100644 PBGitSHA.h delete mode 100644 PBGitSHA.m delete mode 100755 build_libgit2.sh delete mode 160000 libgit2 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 6e08054..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "libgit2"] - path = libgit2 - url = git://github.com/RomainMuller/libgit2.git \ No newline at end of file diff --git a/GLFileView.m b/GLFileView.m index 92baab9..9b6ecab 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -155,7 +155,7 @@ - (void) selectCommit:(NSString*)c { - [historyController selectCommit:[PBGitSHA shaWithString:c]]; + [historyController selectCommit:c]; } // TODO: need to be refactoring diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 92317c4..7cb0c81 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -129,7 +129,6 @@ D8F01C4B12182F19007F729F /* GitX.sdef in Resources */ = {isa = PBXBuildFile; fileRef = D8F01C4A12182F19007F729F /* GitX.sdef */; }; D8F01D531218A164007F729F /* NSApplication+GitXScripting.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F01D521218A164007F729F /* NSApplication+GitXScripting.m */; }; D8F4AB7912298CE200D6D53C /* rewindImage.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D8F4AB7812298CE200D6D53C /* rewindImage.pdf */; }; - D8FBCF19115FA20C0098676A /* PBGitSHA.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FBCF18115FA20C0098676A /* PBGitSHA.m */; }; D8FDD9F711432A12005647F6 /* PBCloneRepositoryPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8FDD9F511432A12005647F6 /* PBCloneRepositoryPanel.xib */; }; D8FDDA6A114335E8005647F6 /* PBGitSVBranchItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA5D114335E8005647F6 /* PBGitSVBranchItem.m */; }; D8FDDA6B114335E8005647F6 /* PBGitSVFolderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA5F114335E8005647F6 /* PBGitSVFolderItem.m */; }; @@ -178,7 +177,6 @@ F5AD56790E79B78100EDAAFE /* PBCommitList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5AD56780E79B78100EDAAFE /* PBCommitList.m */; }; F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5B721C20E05CF7E00AF29DC /* MainMenu.xib */; }; F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C007740E731B48007B84B2 /* PBGitRef.m */; }; - F5C580E50EDA250900995434 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5C580E40EDA250900995434 /* libgit2.a */; }; F5C6F68D0E65FF9300478D97 /* PBGitLane.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */; }; F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DFFA6B0E075D8800617813 /* PBEasyFS.m */; }; F5E424110EA3E4D60046E362 /* PBDiffWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */; }; @@ -214,13 +212,6 @@ remoteGlobalIDString = 913D5E480E55644600CECEA2; remoteInfo = "cli tool"; }; - D8022C1911DFE8ED003C21F6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; - proxyType = 1; - remoteGlobalIDString = D8022B1411DFCE7F003C21F6; - remoteInfo = libgit2; - }; F5643A010F792B4900A579C2 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -417,8 +408,6 @@ D8F01D521218A164007F729F /* NSApplication+GitXScripting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+GitXScripting.m"; sourceTree = ""; }; D8F01D841218A406007F729F /* GitX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX.h; sourceTree = ""; }; D8F4AB7812298CE200D6D53C /* rewindImage.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = rewindImage.pdf; path = Images/rewindImage.pdf; sourceTree = ""; }; - D8FBCF17115FA20C0098676A /* PBGitSHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSHA.h; sourceTree = ""; }; - D8FBCF18115FA20C0098676A /* PBGitSHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSHA.m; sourceTree = ""; }; D8FDD9F611432A12005647F6 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PBCloneRepositoryPanel.xib; sourceTree = ""; }; D8FDDA5C114335E8005647F6 /* PBGitSVBranchItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSVBranchItem.h; sourceTree = ""; }; D8FDDA5D114335E8005647F6 /* PBGitSVBranchItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVBranchItem.m; sourceTree = ""; }; @@ -560,7 +549,6 @@ 911112370E5A097800BF76B4 /* Security.framework in Frameworks */, F580E6AE0E733276009E2D3F /* Sparkle.framework in Frameworks */, F5E4DBFB0EAB58D90013FAFC /* SystemConfiguration.framework in Frameworks */, - F5C580E50EDA250900995434 /* libgit2.a in Frameworks */, D8E3B2B810DC9FB2001096A3 /* ScriptingBridge.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1084,8 +1072,6 @@ F56524EF0E02D45200F03B52 /* PBGitCommit.m */, F5C007730E731B48007B84B2 /* PBGitRef.h */, F5C007740E731B48007B84B2 /* PBGitRef.m */, - D8FBCF17115FA20C0098676A /* PBGitSHA.h */, - D8FBCF18115FA20C0098676A /* PBGitSHA.m */, D8295D281130A1DC00C838E8 /* PBGitHistoryList.h */, D8295D291130A1DC00C838E8 /* PBGitHistoryList.m */, F5FF4E160E0829C20006317A /* PBGitRevList.h */, @@ -1146,22 +1132,6 @@ }; /* End PBXGroup section */ -/* Begin PBXLegacyTarget section */ - D8022B1411DFCE7F003C21F6 /* libgit2 */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "\"${PROJECT_DIR}/build_libgit2.sh\""; - buildConfigurationList = D8022B1C11DFCE98003C21F6 /* Build configuration list for PBXLegacyTarget "libgit2" */; - buildPhases = ( - ); - buildToolPath = /bin/sh; - dependencies = ( - ); - name = libgit2; - passBuildSettingsInEnvironment = 1; - productName = libgit2; - }; -/* End PBXLegacyTarget section */ - /* Begin PBXNativeTarget section */ 551BF110112F371800265053 /* gitx_askpasswd */ = { isa = PBXNativeTarget; @@ -1196,7 +1166,6 @@ 551BF175112F3F3500265053 /* PBXTargetDependency */, 913D5E5A0E5564F400CECEA2 /* PBXTargetDependency */, F5643A020F792B4900A579C2 /* PBXTargetDependency */, - D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */, ); name = GitX; productInstallPath = "$(HOME)/Applications"; @@ -1242,7 +1211,6 @@ 8D1107260486CEB800E47090 /* GitX */, 913D5E480E55644600CECEA2 /* cli tool */, F56439F70F792B2100A579C2 /* Generate PList Prefix */, - D8022B1411DFCE7F003C21F6 /* libgit2 */, 551BF110112F371800265053 /* gitx_askpasswd */, ); }; @@ -1452,7 +1420,6 @@ D8295D2A1130A1DC00C838E8 /* PBGitHistoryList.m in Sources */, D8295DE01130E43900C838E8 /* PBGitHistoryGrapher.m in Sources */, D8E105471157C18200FC28A4 /* PBQLTextView.m in Sources */, - D8FBCF19115FA20C0098676A /* PBGitSHA.m in Sources */, D8022FED11E124C8003C21F6 /* PBGitXMessageSheet.m in Sources */, D8EB616A122F643E00FCCAF4 /* GitXRelativeDateFormatter.m in Sources */, D8F01D531218A164007F729F /* NSApplication+GitXScripting.m in Sources */, @@ -1506,11 +1473,6 @@ target = 913D5E480E55644600CECEA2 /* cli tool */; targetProxy = 913D5E590E5564F400CECEA2 /* PBXContainerItemProxy */; }; - D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D8022B1411DFCE7F003C21F6 /* libgit2 */; - targetProxy = D8022C1911DFE8ED003C21F6 /* PBXContainerItemProxy */; - }; F5643A020F792B4900A579C2 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = F56439F70F792B2100A579C2 /* Generate PList Prefix */; @@ -1820,31 +1782,6 @@ }; name = Release; }; - D8022B1511DFCE7F003C21F6 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = libgit2; - SDKROOT = ""; - }; - name = Debug; - }; - D8022B1611DFCE7F003C21F6 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - PRODUCT_NAME = libgit2; - SDKROOT = ""; - ZERO_LINK = NO; - }; - name = Release; - }; F56439F80F792B2100A579C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1911,15 +1848,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - D8022B1C11DFCE98003C21F6 /* Build configuration list for PBXLegacyTarget "libgit2" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D8022B1511DFCE7F003C21F6 /* Debug */, - D8022B1611DFCE7F003C21F6 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; F56439FD0F792B3600A579C2 /* Build configuration list for PBXAggregateTarget "Generate PList Prefix" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/PBGitCommit.h b/PBGitCommit.h index e77ee32..5ad99e6 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -10,14 +10,13 @@ #import "PBGitRepository.h" #import "PBGitTree.h" #import "PBGitRefish.h" -#import "PBGitSHA.h" extern NSString * const kGitXCommitType; @interface PBGitCommit : NSObject { - PBGitSHA *sha; + NSString *sha; NSString* subject; NSString* author; @@ -33,8 +32,8 @@ extern NSString * const kGitXCommitType; PBGitRepository* repository; } -+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(PBGitSHA *)newSha; -- (id)initWithRepository:(PBGitRepository *)repo andSha:(PBGitSHA *)newSha; ++ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(NSString *)newSha; +- (id)initWithRepository:(PBGitRepository *)repo andSha:(NSString *)newSha; - (void) addRef:(PBGitRef *)ref; - (void) removeRef:(id)ref; @@ -49,7 +48,7 @@ extern NSString * const kGitXCommitType; - (NSString *) shortName; - (NSString *) refishType; -@property (readonly) PBGitSHA *sha; +@property (readonly) NSString *sha; @property (copy) NSString* subject; @property (copy) NSString* author; @property (copy) NSString *committer; diff --git a/PBGitCommit.m b/PBGitCommit.m index 067d6f4..be4afc8 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -7,7 +7,6 @@ // #import "PBGitCommit.h" -#import "PBGitSHA.h" #import "PBGitDefaults.h" @@ -38,12 +37,12 @@ NSString * const kGitXCommitType = @"commit"; return self.tree.children; } -+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(PBGitSHA *)newSha ++ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(NSString *)newSha { return [[self alloc] initWithRepository:repo andSha:newSha]; } -- (id)initWithRepository:(PBGitRepository*) repo andSha:(PBGitSHA *)newSha +- (id)initWithRepository:(PBGitRepository*) repo andSha:(NSString *)newSha { details = nil; repository = repo; @@ -53,7 +52,7 @@ NSString * const kGitXCommitType = @"commit"; - (NSString *)realSha { - return sha.string; + return sha; } - (BOOL) isOnSameBranchAs:(PBGitCommit *)otherCommit diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index 47d9cfd..98827d2 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -11,7 +11,6 @@ #import "PBGitLane.h" #import "PBGitGraphLine.h" #import -#import using namespace std; @@ -48,7 +47,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in PBGitLane *currentLane = NULL; BOOL didFirst = NO; - git_oid commit_oid = [[commit sha] oid]; + NSString *commit_oid = [commit sha]; // First, iterate over earlier columns and pass through any that don't want this commit if (previous != nil) { @@ -88,8 +87,8 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // If we already did the first parent, don't do so again if (!didFirst && currentLanes->size() < MAX_LANES && nParents) { - git_oid parentOID = [[parents objectAtIndex:0] oid]; - PBGitLane *newLane = new PBGitLane(&parentOID); + NSString *parentOID = [parents objectAtIndex:0]; + PBGitLane *newLane = new PBGitLane(parentOID); currentLanes->push_back(newLane); newPos = currentLanes->size(); add_line(lines, ¤tLine, 0, newPos, newPos, newLane->index()); @@ -103,7 +102,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in int parentIndex = 0; for (parentIndex = 1; parentIndex < nParents; ++parentIndex) { - git_oid parentOID = [[parents objectAtIndex:parentIndex] oid]; + NSString *parentOID = [parents objectAtIndex:parentIndex]; int i = 0; BOOL was_displayed = NO; std::list::iterator it = currentLanes->begin(); @@ -123,7 +122,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // Really add this parent addedParent = YES; - PBGitLane *newLane = new PBGitLane(&parentOID); + PBGitLane *newLane = new PBGitLane(parentOID); currentLanes->push_back(newLane); add_line(lines, ¤tLine, 0, currentLanes->size(), newPos, newLane->index()); } @@ -150,7 +149,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // Update the current lane to point to the new parent if (currentLane && nParents > 0) - currentLane->setSha([[parents objectAtIndex:0] oid]); + currentLane->setSha([parents objectAtIndex:0]); else currentLanes->remove(currentLane); diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index a09bc64..840d8c4 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -18,7 +18,7 @@ @class QLPreviewPanel; @class PBCommitList; @class GLFileView; -@class PBGitSHA; +@class NSString; @class PBHistorySearchController; @@ -71,7 +71,7 @@ - (IBAction) setTreeView:(id)sender; - (IBAction) setBranchFilter:(id)sender; -- (void)selectCommit:(PBGitSHA *)commit; +- (void)selectCommit:(NSString *)commit; - (IBAction) refresh:(id)sender; - (IBAction) toggleQLPreviewPanel:(id)sender; - (IBAction) openSelectedFile:(id)sender; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index d69eb61..4d1a787 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -447,7 +447,7 @@ commitList.useAdjustScroll = NO; } -- (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA +- (NSArray *) selectedObjectsForSHA:(NSString *)commitSHA { NSPredicate *selection = [NSPredicate predicateWithFormat:@"sha == %@", commitSHA]; NSArray *selectedCommits = [[commitController content] filteredArrayUsingPredicate:selection]; @@ -458,7 +458,7 @@ return selectedCommits; } -- (void)selectCommit:(PBGitSHA *)commitSHA +- (void)selectCommit:(NSString *)commitSHA { if (!forceSelectionUpdate && [[[[commitController selectedObjects] lastObject] sha] isEqual:commitSHA]) return; diff --git a/PBGitHistoryGrapher.m b/PBGitHistoryGrapher.m index 062c7ae..2d45ad4 100644 --- a/PBGitHistoryGrapher.m +++ b/PBGitHistoryGrapher.m @@ -8,7 +8,6 @@ #import "PBGitHistoryGrapher.h" #import "PBGitGrapher.h" -#import "PBGitSHA.h" @implementation PBGitHistoryGrapher @@ -47,7 +46,7 @@ for (PBGitCommit *commit in revList) { if ([currentThread isCancelled]) return; - PBGitSHA *commitSHA = [commit sha]; + NSString *commitSHA = [commit sha]; if (viewAllBranches || [searchSHAs containsObject:commitSHA]) { [grapher decorateCommit:commit]; [commits addObject:commit]; diff --git a/PBGitHistoryList.h b/PBGitHistoryList.h index 75e1c6c..c0a444b 100644 --- a/PBGitHistoryList.h +++ b/PBGitHistoryList.h @@ -14,7 +14,6 @@ @class PBGitRef; @class PBGitRevList; @class PBGitHistoryGrapher; -@class PBGitSHA; @interface PBGitHistoryList : NSObject { PBGitRepository *repository; @@ -22,7 +21,7 @@ PBGitRevList *projectRevList; PBGitRevList *currentRevList; - PBGitSHA *lastSHA; + NSString *lastSHA; NSSet *lastRefSHAs; NSInteger lastBranchFilter; PBGitRef *lastRemoteRef; diff --git a/PBGitHistoryList.m b/PBGitHistoryList.m index 0ab1324..34b1485 100644 --- a/PBGitHistoryList.m +++ b/PBGitHistoryList.m @@ -11,7 +11,6 @@ #import "PBGitRevList.h" #import "PBGitGrapher.h" #import "PBGitHistoryGrapher.h" -#import "PBGitSHA.h" @@ -168,7 +167,7 @@ NSMutableSet *baseCommitSHAs = [NSMutableSet set]; NSDictionary *refs = repository.refs; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *ref in [refs objectForKey:sha]) if ([ref isBranch] || [ref isTag]) [baseCommitSHAs addObject:sha]; @@ -187,7 +186,7 @@ PBGitRef *remoteRef = [[repository.currentBranch ref] remoteRef]; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *ref in [refs objectForKey:sha]) if ([remoteRef isEqualToRef:[ref remoteRef]]) [baseCommitSHAs addObject:sha]; @@ -203,7 +202,7 @@ return [NSMutableSet setWithObject:lastSHA]; else if ([repository.currentBranch isSimpleRef]) { PBGitRef *currentRef = [repository.currentBranch ref]; - PBGitSHA *sha = [repository shaForRef:currentRef]; + NSString *sha = [repository shaForRef:currentRef]; if (sha) return [NSMutableSet setWithObject:sha]; } @@ -273,7 +272,7 @@ return NO; } - PBGitSHA *revSHA = [repository shaForRef:[rev ref]]; + NSString *revSHA = [repository shaForRef:[rev ref]]; if ([revSHA isEqual:lastSHA] && (lastBranchFilter == repository.currentBranchFilter)) return NO; diff --git a/PBGitLane.h b/PBGitLane.h index 136e5b3..2591621 100644 --- a/PBGitLane.h +++ b/PBGitLane.h @@ -6,46 +6,32 @@ // Copyright 2008 __MyCompanyName__. All rights reserved. // #import -#include class PBGitLane { static int s_colorIndex; - git_oid d_sha; + NSString *d_sha; int d_index; public: - PBGitLane(git_oid *sha) - { - d_index = s_colorIndex++; - d_sha = *sha; - } - PBGitLane(NSString *sha) { - git_oid_mkstr(&d_sha, [sha UTF8String]); d_index = s_colorIndex++; + d_sha = sha; } - + PBGitLane() { d_index = s_colorIndex++; } - bool isCommit(git_oid sha) const + bool isCommit(NSString *sha) const { - return !git_oid_cmp(&d_sha, &sha); - } - - void setSha(git_oid sha); - - git_oid const *sha() const - { - return &d_sha; + return [d_sha isEqual:sha]; } + void setSha(NSString *sha); int index() const; - static void resetColors(); }; \ No newline at end of file diff --git a/PBGitLane.mm b/PBGitLane.mm index 2ae767f..6b5f9df 100644 --- a/PBGitLane.mm +++ b/PBGitLane.mm @@ -29,7 +29,7 @@ int PBGitLane::index() const return d_index; } -void PBGitLane::setSha(git_oid sha) +void PBGitLane::setSha(NSString *sha) { d_sha = sha; } diff --git a/PBGitRepository.h b/PBGitRepository.h index 7e4cd6f..eb2f57c 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -42,7 +42,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { @class PBGitWindowController; @class PBGitCommit; -@class PBGitSHA; +@class NSString; @interface PBGitRepository : NSDocument { PBGitHistoryList* revisionList; @@ -55,7 +55,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { NSMutableDictionary *refs; PBGitRevSpecifier *_headRef; // Caching - PBGitSHA* _headSha; + NSString* _headSha; PBStashController *stashController; PBSubmoduleController *submoduleController; @@ -112,13 +112,13 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params; - (void) lazyReload; - (PBGitRevSpecifier*)headRef; -- (PBGitSHA *)headSHA; +- (NSString *)headSHA; - (PBGitCommit *)headCommit; -- (PBGitSHA *)shaForRef:(PBGitRef *)ref; +- (NSString *)shaForRef:(PBGitRef *)ref; - (PBGitCommit *)commitForRef:(PBGitRef *)ref; -- (PBGitCommit *)commitForSHA:(PBGitSHA *)sha; -- (BOOL)isOnSameBranch:(PBGitSHA *)baseSHA asSHA:(PBGitSHA *)testSHA; -- (BOOL)isSHAOnHeadBranch:(PBGitSHA *)testSHA; +- (PBGitCommit *)commitForSHA:(NSString *)sha; +- (BOOL)isOnSameBranch:(NSString *)baseSHA asSHA:(NSString *)testSHA; +- (BOOL)isSHAOnHeadBranch:(NSString *)testSHA; - (BOOL)isRefOnHeadBranch:(PBGitRef *)testRef; - (BOOL)checkRefFormat:(NSString *)refName; - (BOOL)refExists:(PBGitRef *)ref; diff --git a/PBGitRepository.m b/PBGitRepository.m index 69d8405..aa635bf 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -274,11 +274,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; { NSString* type = [components objectAtIndex:1]; - PBGitSHA *sha; + NSString *sha; if ([type isEqualToString:@"tag"] && [components count] == 4) - sha = [PBGitSHA shaWithString:[components objectAtIndex:3]]; + sha = [components objectAtIndex:3]; else - sha = [PBGitSHA shaWithString:[components objectAtIndex:2]]; + sha = [components objectAtIndex:2]; if(!sha) { NSLog(@"sha was nil...? ref=%@, components=%@",ref,components); @@ -374,7 +374,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return _headRef; } -- (PBGitSHA *)headSHA +- (NSString *)headSHA { if (! _headSha) [self headRef]; @@ -387,12 +387,12 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return [self commitForSHA:[self headSHA]]; } -- (PBGitSHA *)shaForRef:(PBGitRef *)ref +- (NSString *)shaForRef:(PBGitRef *)ref { if (!ref) return nil; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *existingRef in [refs objectForKey:sha]) if ([existingRef isEqualToRef:ref]) return sha; @@ -403,7 +403,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; if (retValue || [shaForRef isEqualToString:@""]) return nil; - return [PBGitSHA shaWithString:shaForRef]; + return shaForRef; } - (PBGitCommit *)commitForRef:(PBGitRef *)ref @@ -414,7 +414,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return [self commitForSHA:[self shaForRef:ref]]; } -- (PBGitCommit *)commitForSHA:(PBGitSHA *)sha +- (PBGitCommit *)commitForSHA:(NSString *)sha { if (!sha) return nil; @@ -431,7 +431,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return nil; } -- (BOOL)isOnSameBranch:(PBGitSHA *)branchSHA asSHA:(PBGitSHA *)testSHA +- (BOOL)isOnSameBranch:(NSString *)branchSHA asSHA:(NSString *)testSHA { if (!branchSHA || !testSHA) return NO; @@ -444,7 +444,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSMutableSet *searchSHAs = [NSMutableSet setWithObject:branchSHA]; for (PBGitCommit *commit in revList) { - PBGitSHA *commitSHA = [commit sha]; + NSString *commitSHA = [commit sha]; if ([searchSHAs containsObject:commitSHA]) { if ([testSHA isEqual:commitSHA]) return YES; @@ -458,12 +458,12 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return NO; } -- (BOOL)isSHAOnHeadBranch:(PBGitSHA *)testSHA +- (BOOL)isSHAOnHeadBranch:(NSString *)testSHA { if (!testSHA) return NO; - PBGitSHA *headSHA = [self headSHA]; + NSString *headSHA = [self headSHA]; if ([testSHA isEqual:headSHA]) return YES; diff --git a/PBGitRevList.mm b/PBGitRevList.mm index b787e59..4295b3c 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -17,8 +17,6 @@ #include #include -#include - using namespace std; @@ -159,11 +157,11 @@ using namespace std; } } - git_oid oid; - if(git_oid_mkstr(&oid, sha.c_str())!=GIT_SUCCESS) + NSString *oid=[NSString stringWithCString:sha.c_str() encoding:encoding]; + if([oid length]!=40) break; - PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:[PBGitSHA shaWithOID:oid]]; + PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:oid]; if (showSign) [newCommit setSign: sign]; @@ -176,6 +174,7 @@ using namespace std; string parentString; getline(stream, parentString, '\1'); + if (parentString.size() != 0) { if (((parentString.size() + 1) % 41) != 0) { @@ -185,9 +184,10 @@ using namespace std; int nParents = (parentString.size() + 1) / 41; NSMutableArray *parents = [NSMutableArray arrayWithCapacity:nParents]; int parentIndex; - for (parentIndex = 0; parentIndex < nParents; ++parentIndex) - [parents addObject:[PBGitSHA shaWithCString:parentString.substr(parentIndex * 41, 40).c_str()]]; - + for (parentIndex = 0; parentIndex < nParents; ++parentIndex) { + NSString *pOid=[NSString stringWithCString:parentString.substr(parentIndex * 41, 40).c_str() encoding:encoding]; + [parents addObject:pOid]; + } [newCommit setParents:parents]; } diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m index 65889a6..df8cca1 100644 --- a/PBGitRevisionCell.m +++ b/PBGitRevisionCell.m @@ -60,10 +60,10 @@ - (BOOL) isCurrentCommit { - PBGitSHA *thisSha = [self.objectValue sha]; + NSString *thisSha = [self.objectValue sha]; PBGitRepository* repository = [self.objectValue repository]; - PBGitSHA *currentSha = [repository headSHA]; + NSString *currentSha = [repository headSHA]; return [currentSha isEqual:thisSha]; } diff --git a/PBGitSHA.h b/PBGitSHA.h deleted file mode 100644 index 15eeeb3..0000000 --- a/PBGitSHA.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// PBGitSHA.h -// GitX -// -// Created by BrotherBard on 3/28/10. -// Copyright 2010 BrotherBard. All rights reserved. -// - -#import -#include - - -@interface PBGitSHA : NSObject { - git_oid oid; - NSString *string; -} - - -+ (PBGitSHA *)shaWithOID:(git_oid)oid; -+ (PBGitSHA *)shaWithString:(NSString *)shaString; -+ (PBGitSHA *)shaWithCString:(const char *)shaCString; - -- (BOOL)isEqualToOID:(git_oid)other_oid; - -@property (readonly) git_oid oid; -@property (readonly) NSString *string; - -@end diff --git a/PBGitSHA.m b/PBGitSHA.m deleted file mode 100644 index a310040..0000000 --- a/PBGitSHA.m +++ /dev/null @@ -1,139 +0,0 @@ -// -// PBGitSHA.m -// GitX -// -// Created by BrotherBard on 3/28/10. -// Copyright 2010 BrotherBard. All rights reserved. -// - -#import "PBGitSHA.h" -#import - -@interface PBGitSHA () - -- (id)initWithOID:(git_oid)g_oid; - -@end - - -@implementation PBGitSHA - - -@synthesize oid; -@synthesize string; - - -+ (PBGitSHA *)shaWithOID:(git_oid)oid -{ - return [[PBGitSHA alloc] initWithOID:oid]; -} - - -+ (PBGitSHA *)shaWithString:(NSString *)shaString -{ - git_oid oid; - int err = git_oid_mkstr(&oid, [shaString UTF8String]); - if (err == GIT_ENOTOID) - return nil; - - return [self shaWithOID:oid]; -} - - -+ (PBGitSHA *)shaWithCString:(const char *)shaCString -{ - git_oid oid; - int err = git_oid_mkstr(&oid, shaCString); - if (err == GIT_ENOTOID) - return nil; - - return [self shaWithOID:oid]; -} - - -+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector -{ - return NO; -} - - -+ (BOOL)isKeyExcludedFromWebScript:(const char *)name -{ - return NO; -} - - - -#pragma mark - -#pragma mark PBGitSHA - -- (id)initWithOID:(git_oid)g_oid -{ - self = [super init]; - if (!self) - return nil; - - oid = g_oid; - - return self; -} - - -- (NSString *)string -{ - if (!string) { - char *hex = git_oid_allocfmt(&oid); - if (hex == NULL) - return nil; - string = [NSString stringWithUTF8String:hex]; - free(hex); - } - - return string; -} - - -- (BOOL)isEqual:(id)otherSHA -{ - if (self == otherSHA) - return YES; - - git_oid other_oid = [(PBGitSHA *)otherSHA oid]; - return git_oid_cmp(&oid, &other_oid) == 0; -} - - -- (BOOL)isEqualToOID:(git_oid)other_oid -{ - return git_oid_cmp(&oid, &other_oid) == 0; -} - - -- (NSUInteger)hash -{ - NSUInteger hash; - memcpy(&hash, &(oid.id), sizeof(NSUInteger)); - - return hash; -} - - -- (NSString *)description -{ - return [self string]; -} - - - -#pragma mark - -- (id)copyWithZone:(NSZone *)zone -{ - git_oid oidCopy; - git_oid_cpy(&oidCopy, &oid); - PBGitSHA *copy = [[[self class] allocWithZone:zone] initWithOID:oidCopy]; - - return copy; -} - -@end diff --git a/PBHistorySearchController.m b/PBHistorySearchController.m index e028563..6f7da2b 100644 --- a/PBHistorySearchController.m +++ b/PBHistorySearchController.m @@ -442,7 +442,7 @@ for (NSString *resultSHA in resultsArray) { NSUInteger index = 0; for (PBGitCommit *commit in [commitController arrangedObjects]) { - if ([resultSHA isEqualToString:commit.sha.string]) { + if ([resultSHA isEqualToString:commit.sha]) { [indexes addIndex:index]; break; } diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index 74c600f..f7a7cf8 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -14,13 +14,13 @@ #import "PBRefContextDelegate.h" -@class PBGitSHA; +@class NSString; @interface PBWebHistoryController : PBWebController { IBOutlet PBGitHistoryController* historyController; IBOutlet id contextMenuDelegate; - PBGitSHA* currentSha; + NSString* currentSha; NSString* diff; } diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index a05bfe8..5d1bd47 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -8,7 +8,6 @@ #import "PBWebHistoryController.h" #import "PBGitDefaults.h" -#import "PBGitSHA.h" #import "GLFileView.h" #import @@ -57,7 +56,7 @@ // but this caused some funny behaviour because NSTask's and NSThread's don't really // like each other. Instead, just do it async. - NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", [currentSha string], nil]; + NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil]; if (![PBGitDefaults showWhitespaceDifferences]) [taskArguments insertObject:@"-w" atIndex:1]; @@ -107,17 +106,17 @@ NSMutableDictionary *stats=[self parseStats:details]; // File list - NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; NSString *diffs=[GLFileView parseDiff:d]; NSString *html=[NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",[currentSha string]]]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[currentSha string]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; @@ -223,7 +222,7 @@ - (void)selectCommit:(NSString *)sha { - [historyController selectCommit:[PBGitSHA shaWithString:sha]]; + [historyController selectCommit:sha]; } // TODO: need to be refactoring diff --git a/build_libgit2.sh b/build_libgit2.sh deleted file mode 100755 index 15b92ea..0000000 --- a/build_libgit2.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -# build_libgit2.sh -# GitX -# -# Created by BrotherBard on 7/3/10. -# Copyright 2010 BrotherBard. All rights reserved. -# -# based on: http://log.yeahrightkeller.com/post/270155578/run-script-while-cleaning-in-xcode - -buildAction () { - echo "Building libgit2..." - if [[ -d .git ]] - then - if [ "$(which git)" == "" ]; then - echo "git not found" - exit -1 - fi - git submodule init - git submodule sync - git submodule update - cd libgit2 - CFLAGS='-arch i386 -arch x86_64' - ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure - if [ $? != 0 ]; then - echo "error: failed to waf configure" - exit -1 - fi - ./waf build-static - if [ $? != 0 ]; then - echo "error: failed to waf build-static" - exit -1 - fi - ranlib $TARGET_TEMP_DIR/static/libgit2.a - cp $TARGET_TEMP_DIR/static/libgit2.a $TARGET_BUILD_DIR - else - echo "error: Not a git repository." - echo "error: clone GitX first so that the libgit2 submodule can be updated" - exit 1 - fi -} - -cleanAction () { - echo "Cleaning libgit2..." - cd libgit2 - ./waf clean -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# MAIN - -#echo "Running with ACTION=${ACTION}" - -case $ACTION in - # NOTE: it gets set to "" rather than "build" when doing a build. - "") - buildAction - ;; - - "clean") - cleanAction - ;; -esac - -exit 0 - diff --git a/libgit2 b/libgit2 deleted file mode 160000 index d1685ac..0000000 --- a/libgit2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d1685ac7e91c5269cf01f6ab57c2c4705a14e6bc From 2158f1e6c7a54b254318258b50fc359ad51dda24 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 20 May 2011 21:02:37 -0600 Subject: [PATCH 29/63] start on stash work --- PBGitStashController.h | 30 ++++++++++++++++++++++++++++++ PBGitStashController.m | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 PBGitStashController.h create mode 100644 PBGitStashController.m diff --git a/PBGitStashController.h b/PBGitStashController.h new file mode 100644 index 0000000..0f04e3a --- /dev/null +++ b/PBGitStashController.h @@ -0,0 +1,30 @@ +// +// PBGitHistoryView.h +// GitX +// +// Created by David Catmull on 20-06-11. +// Copyright 2011. All rights reserved. +// + +#import "PBViewController.h" + +// Controls the view displaying a stash diff +@interface PBGitStashController : PBViewController { + IBOutlet id webView; + IBOutlet PBWebStashController *webHistoryController; +} + +- (void) c:(PBGitStash)stash; + +@end + +@interface PBWebStashController : PBWebController { + PBGitStash* currentStash; + NSString* diff; +} + +- (void) changeContentTo:(PBGitStash*)stash; + +@property (readonly) NSString* diff; + +@end diff --git a/PBGitStashController.m b/PBGitStashController.m new file mode 100644 index 0000000..8be1d96 --- /dev/null +++ b/PBGitStashController.m @@ -0,0 +1,24 @@ +// +// PBGitHistoryView.h +// GitX +// +// Created by David Catmull on 20-06-11. +// Copyright 2011. All rights reserved. +// + +#import "PBGitStashController.h" + +@implementation PBGitStashController + + +- (void) awakeFromNib +{ +} + +- (void) showStash:(PBGitStash)stash +{ + // git stash show -p [stash stashSourceMessage] + [webController +} + +@end From 883aa1af83718ae8d8dbe0b9b36051ef7094a8c7 Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Wed, 25 May 2011 13:15:39 -0400 Subject: [PATCH 30/63] Enabling sudden termination on Mac OS X 10.6+. --- Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Info.plist b/Info.plist index a08c1fa..d5a8da8 100644 --- a/Info.plist +++ b/Info.plist @@ -60,6 +60,8 @@ MainMenu NSPrincipalClass NSApplication + NSSupportsSuddenTermination + SUFeedURL http://gitx.laullon.com/appcast.xml NSServices From 467f7eeb7551fd2fa65d3c5fbb906d82f9bf433c Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Wed, 25 May 2011 13:43:25 -0400 Subject: [PATCH 31/63] Using NSWorkspaceLaunchDefault in gitx cli. --- gitx.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitx.m b/gitx.m index 8c1ae4e..fc8d309 100644 --- a/gitx.m +++ b/gitx.m @@ -169,7 +169,7 @@ void handleOpenRepository(NSURL *repositoryURL, NSMutableArray *arguments) // this allows the repository document to modify itself before it shows it's GUI BOOL didOpenURLs = [[NSWorkspace sharedWorkspace] openURLs:[NSArray arrayWithObject:repositoryURL] withAppBundleIdentifier:kGitXBundleIdentifier - options:0 + options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:recordDescriptor launchIdentifiers:NULL]; if (!didOpenURLs) { From 001f49b0347501c1892989943a3dfa6ba0035b09 Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Wed, 25 May 2011 13:45:19 -0400 Subject: [PATCH 32/63] Disabling "Open Current Directory on Launch" by default. Adding a checkbox in Preferences window to control this setting. This fixed a problem happening on Mac OS X Lion where more than one GitX window is shown when using gitx CLI. --- English.lproj/Preferences.xib | 107 ++++++++++++++++++++++++++-------- PBGitDefaults.m | 2 +- 2 files changed, 84 insertions(+), 25 deletions(-) diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib index 4afaeed..73cdd07 100644 --- a/English.lproj/Preferences.xib +++ b/English.lproj/Preferences.xib @@ -2,13 +2,13 @@ 1050 - 10J869 - 1305 - 1038.35 - 461.00 + 11A459e + 1565 + 1121.2 + 557.00 com.apple.InterfaceBuilder.CocoaPlugin - 1305 + 1565 YES @@ -58,7 +58,7 @@ 268 - {{18, 185}, {158, 18}} + {{18, 197}, {158, 18}} @@ -91,7 +91,7 @@ 268 - {{17, 22}, {166, 17}} + {{17, 34}, {166, 17}} @@ -125,7 +125,7 @@ 268 - {{182, 12}, {137, 32}} + {{182, 24}, {137, 32}} @@ -148,7 +148,7 @@ 268 - {{248, 117}, {41, 22}} + {{248, 129}, {41, 22}} @@ -180,7 +180,7 @@ 268 - {{121, 119}, {122, 17}} + {{121, 131}, {122, 17}} @@ -198,7 +198,7 @@ 268 - {{18, 145}, {273, 18}} + {{18, 157}, {273, 18}} @@ -222,7 +222,7 @@ 268 - {{17, 92}, {99, 17}} + {{17, 104}, {99, 17}} @@ -248,7 +248,7 @@ NSFilenamesPboardType - {{121, 88}, {179, 22}} + {{121, 100}, {179, 22}} @@ -272,7 +272,7 @@ 268 - {{118, 52}, {192, 28}} + {{118, 64}, {192, 28}} @@ -290,7 +290,7 @@ 268 - {{306, 92}, {54, 14}} + {{306, 104}, {54, 14}} @@ -317,7 +317,7 @@ 268 - {{18, 165}, {203, 18}} + {{18, 177}, {203, 18}} @@ -338,14 +338,38 @@ 25 - + 268 - {{18, 205}, {279, 18}} + {{18, 217}, {279, 18}} YES + + -2080244224 + 0 + Try to open current directory on launch + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{18, 237}, {279, 18}} + + + + YES -2080244224 0 @@ -365,7 +389,7 @@ 268 - {{18, 225}, {207, 18}} + {{18, 257}, {207, 18}} @@ -389,7 +413,7 @@ 268 - {{18, 245}, {207, 18}} + {{18, 277}, {207, 18}} @@ -411,7 +435,7 @@ - {401, 281} + {401, 313} @@ -592,7 +616,7 @@ - EEEE, MMMM d, yyyy h:mm:ss a + EEEE, d MMMM, y h:mm:ss a NO @@ -695,7 +719,7 @@ YES - 256 + 274 YES @@ -1286,6 +1310,22 @@ 161 + + + value: values.PBOpenCurDirOnLaunch + + + + + + value: values.PBOpenCurDirOnLaunch + value + values.PBOpenCurDirOnLaunch + 2 + + + 165 + @@ -1333,6 +1373,7 @@ + General @@ -1805,6 +1846,20 @@ + + 162 + + + YES + + + + + + 163 + + + @@ -1854,6 +1909,8 @@ 155.IBPluginDependency 156.IBPluginDependency 16.IBPluginDependency + 162.IBPluginDependency + 163.IBPluginDependency 17.IBPluginDependency 18.IBPluginDependency 19.IBPluginDependency @@ -1968,6 +2025,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{324, 683}, {400, 139}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2017,7 +2076,7 @@ - 161 + 165 diff --git a/PBGitDefaults.m b/PBGitDefaults.m index 3534de7..13895d7 100644 --- a/PBGitDefaults.m +++ b/PBGitDefaults.m @@ -56,7 +56,7 @@ forKey:kRefreshAutomatically]; [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kUseAskPasswd]; - [defaultValues setObject:[NSNumber numberWithBool:YES] + [defaultValues setObject:[NSNumber numberWithBool:NO] forKey:kOpenCurDirOnLaunch]; [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:kShowOpenPanelOnLaunch]; From 25b65ac21a1293c97362900eb78cc22678bbcfac Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Wed, 25 May 2011 13:45:28 -0400 Subject: [PATCH 33/63] Ignoring .DS_Store. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6492eef..39b9099 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store build build/revision ._* From 59701cbe73b82b2772b1550f16274d96e3b52893 Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Thu, 26 May 2011 23:21:40 -0400 Subject: [PATCH 34/63] Reworking html resources. For some reason, without this change none of the CSS/JS is being loaded on Lion. --- PBWebController.m | 10 +++-- html/views/blame/index.html | 70 ++++++++++++++++---------------- html/views/commit/index.html | 17 ++++---- html/views/diff/index.html | 14 +++---- html/views/fileview/index.html | 73 +++++++++++++++++----------------- html/views/history/index.html | 19 ++++----- html/views/log/index.html | 14 +++---- html/views/source/index.html | 15 +++---- 8 files changed, 119 insertions(+), 113 deletions(-) diff --git a/PBWebController.m b/PBWebController.m index f6cbee9..4d2e3c4 100644 --- a/PBWebController.m +++ b/PBWebController.m @@ -23,9 +23,6 @@ - (void) awakeFromNib { - NSString *path = [NSString stringWithFormat:@"html/views/%@", startFile]; - NSString* file = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path]; - NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]]; callbacks = [NSMapTable mapTableWithKeyOptions:(NSPointerFunctionsObjectPointerPersonality|NSPointerFunctionsStrongMemory) valueOptions:(NSPointerFunctionsObjectPointerPersonality|NSPointerFunctionsStrongMemory)]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -38,7 +35,12 @@ [view setUIDelegate:self]; [view setFrameLoadDelegate:self]; [view setResourceLoadDelegate:self]; - [[view mainFrame] loadRequest:request]; + + NSURL *resourceURL = [[[NSBundle mainBundle] resourceURL] URLByStandardizingPath]; + NSURL *baseURL = [[resourceURL URLByAppendingPathComponent:@"html/views" isDirectory:YES] URLByAppendingPathComponent:startFile isDirectory:YES]; + + NSURL *fileURL = [baseURL URLByAppendingPathComponent:@"index.html" isDirectory:NO]; + [[view mainFrame] loadRequest:[NSURLRequest requestWithURL:fileURL]]; } - (WebScriptObject *) script diff --git a/html/views/blame/index.html b/html/views/blame/index.html index a6301a7..a46071c 100644 --- a/html/views/blame/index.html +++ b/html/views/blame/index.html @@ -1,41 +1,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + +
diff --git a/html/views/commit/index.html b/html/views/commit/index.html index 54698da..e04c0a6 100644 --- a/html/views/commit/index.html +++ b/html/views/commit/index.html @@ -1,15 +1,16 @@ Diff for file - - - - - + + + + + + + - - - + + diff --git a/html/views/diff/index.html b/html/views/diff/index.html index aa9051f..e44ae8f 100644 --- a/html/views/diff/index.html +++ b/html/views/diff/index.html @@ -1,13 +1,13 @@ - + + + + - - + + diff --git a/html/views/fileview/index.html b/html/views/fileview/index.html index 4684f22..689a9dc 100644 --- a/html/views/fileview/index.html +++ b/html/views/fileview/index.html @@ -1,41 +1,42 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/html/views/history/index.html b/html/views/history/index.html index 12ae76a..d8c62c9 100644 --- a/html/views/history/index.html +++ b/html/views/history/index.html @@ -1,17 +1,18 @@ Details for commit - + + + - - - - + - +
diff --git a/html/views/log/index.html b/html/views/log/index.html index b4889dc..50a69f3 100644 --- a/html/views/log/index.html +++ b/html/views/log/index.html @@ -1,13 +1,13 @@ - + + + + - - + + diff --git a/html/views/source/index.html b/html/views/source/index.html index a16941a..356c142 100644 --- a/html/views/source/index.html +++ b/html/views/source/index.html @@ -1,12 +1,13 @@ - - - - - - - + + + + + + + +
From ff833ea880ce8ca29218aa6051261ef147b53b8c Mon Sep 17 00:00:00 2001 From: Roustem Karimov Date: Thu, 26 May 2011 23:27:13 -0400 Subject: [PATCH 35/63] Fixed GitX URL scheme problem (On Lion it always comes back as 'gitx'). --- PBGitXProtocol.m | 2 +- PBWebController.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PBGitXProtocol.m b/PBGitXProtocol.m index ea0e682..62df9c9 100644 --- a/PBGitXProtocol.m +++ b/PBGitXProtocol.m @@ -26,7 +26,7 @@ + (BOOL) canInitWithRequest:(NSURLRequest *)request { - return [[[request URL] scheme] isEqualToString:@"GitX"]; + return [[[[request URL] scheme] lowercaseString] isEqualToString:@"gitx"]; } + (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request diff --git a/PBWebController.m b/PBWebController.m index 4d2e3c4..c325d77 100644 --- a/PBWebController.m +++ b/PBWebController.m @@ -93,7 +93,8 @@ return request; // TODO: Change this to canInitWithRequest - if ([[[request URL] scheme] isEqualToString:@"GitX"]) { + NSString *scheme = [[[request URL] scheme] lowercaseString]; + if ([scheme isEqualToString:@"gitx"]) { NSMutableURLRequest *newRequest = [request mutableCopy]; [newRequest setRepository:self.repository]; return newRequest; From 9b0ce4ca3c585e04cc6ed1d9c724b7e724993edb Mon Sep 17 00:00:00 2001 From: David Catmull Date: Thu, 26 May 2011 21:48:17 -0600 Subject: [PATCH 36/63] forward declarations --- Commands/PBCommandFactory.h | 1 + PBGitRepository.h | 8 +++----- PBGitRepository.m | 15 +++++++++------ PBGitSidebarController.m | 1 + PBRefController.m | 1 + 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Commands/PBCommandFactory.h b/Commands/PBCommandFactory.h index 477a52b..1a4a084 100644 --- a/Commands/PBCommandFactory.h +++ b/Commands/PBCommandFactory.h @@ -7,6 +7,7 @@ // #import "PBGitRepository.h" +#import "PBPresentable.h" @protocol PBCommandFactory + (NSArray *) commandsForObject:(id) object repository:(PBGitRepository *) repository; diff --git a/PBGitRepository.h b/PBGitRepository.h index f709f42..62fd7bc 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -12,10 +12,6 @@ #import "PBGitConfig.h" #import "PBGitRefish.h" -#import "PBStashController.h" -#import "PBGitResetController.h" -#import "PBSubmoduleController.h" - extern NSString* PBGitRepositoryErrorDomain; typedef enum branchFilterTypes { kGitXAllBranchesFilter = 0, @@ -42,7 +38,9 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { @class PBGitWindowController; @class PBGitCommit; -@class NSString; +@class PBGitResetController; +@class PBStashController; +@class PBSubmoduleController; @interface PBGitRepository : NSDocument { PBGitHistoryList* revisionList; diff --git a/PBGitRepository.m b/PBGitRepository.m index 90444e1..4011387 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -12,14 +12,17 @@ #import "PBGitBinary.h" #import "NSFileHandleExt.h" -#import "PBEasyPipe.h" -#import "PBGitRef.h" -#import "PBGitRevSpecifier.h" -#import "PBRemoteProgressSheet.h" -#import "PBGitRevList.h" -#import "PBGitDefaults.h" #import "GitXScriptingConstants.h" +#import "PBEasyPipe.h" +#import "PBGitDefaults.h" +#import "PBGitRef.h" +#import "PBGitResetController.h" +#import "PBGitRevList.h" +#import "PBGitRevSpecifier.h" #import "PBHistorySearchController.h" +#import "PBRemoteProgressSheet.h" +#import "PBStashController.h" +#import "PBSubmoduleController.h" #import "PBGitStash.h" #import "PBGitSubmodule.h" diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 276fa75..bb84afa 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -23,6 +23,7 @@ #import "PBCommandMenuItem.h" #import "PBGitStash.h" #import "PBGitSubmodule.h" +#import "PBSubmoduleController.h" static NSString * const kObservingContextStashes = @"stashesChanged"; static NSString * const kObservingContextSubmodules = @"submodulesChanged"; diff --git a/PBRefController.m b/PBRefController.m index 34e22da..c12a18f 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -13,6 +13,7 @@ #import "PBCreateTagSheet.h" #import "PBGitDefaults.h" #import "PBDiffWindowController.h" +#import "PBGitResetController.h" #import "PBArgumentPickerController.h" From 4e54ff92fb36982c8f28e2dcd013052d12ac628e Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 27 May 2011 11:46:48 +0200 Subject: [PATCH 37/63] Revert "get back the old gitx_asskpasswd" This reverts commit fb6abc7de72d3913fd3dab3eec2ea41fc52c7349. --- ApplicationController.m | 4 +- gitx_askpasswd_main.m | 355 ++++++++++++++++++++++++---------------- 2 files changed, 218 insertions(+), 141 deletions(-) diff --git a/ApplicationController.m b/ApplicationController.m index 703da02..ad7149c 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -68,8 +68,8 @@ if ([PBGitDefaults useAskPasswd]) { // Make sure Git's SSH password requests get forwarded to our little UI tool: - setenv( "SSH_ASKPASS", [[[NSBundle mainBundle] pathForResource: @"gitx_askpasswd" ofType: @""] UTF8String], 1 ); - setenv( "DISPLAY", "localhost:0", 1 ); + setenv( "SSH_ASKPASS", [[[NSBundle mainBundle] pathForResource: @"gitx_askpasswd" ofType: @""] UTF8String], 1 ); + setenv( "DISPLAY", "localhost:0", 1 ); } [self registerServices]; diff --git a/gitx_askpasswd_main.m b/gitx_askpasswd_main.m index 07a7dbb..75a0a34 100644 --- a/gitx_askpasswd_main.m +++ b/gitx_askpasswd_main.m @@ -9,166 +9,243 @@ #include #import +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#define OKBUTTONWIDTH 100.0 -#define OKBUTTONHEIGHT 24.0 -#define CANCELBUTTONWIDTH 100.0 -#define CANCELBUTTONHEIGHT 24.0 -#define PASSHEIGHT 22.0 -#define PASSLABELHEIGHT 16.0 -#define WINDOWAUTOSAVENAME @"GitXAskPasswordWindowFrame" +#define OKBUTTONWIDTH 100.0 +#define OKBUTTONHEIGHT 24.0 +#define CANCELBUTTONWIDTH 100.0 +#define CANCELBUTTONHEIGHT 24.0 +#define PASSHEIGHT 22.0 +#define PASSLABELHEIGHT 16.0 +#define WINDOWAUTOSAVENAME @"GitXAskPasswordWindowFrame" -@interface GAPAppDelegate : NSObject +@interface GAPAppDelegate : NSObject /**/ { - NSPanel* mPasswordPanel; - NSSecureTextField* mPasswordField; } --(NSPanel*) passwordPanel; - --(IBAction) doOKButton: (id)sender; --(IBAction) doCancelButton: (id)sender; - @end +NSString* url; +OSStatus StorePasswordKeychain (const char *url, UInt32 urlLength, void* password,UInt32 passwordLength); -@implementation GAPAppDelegate --(NSPanel*) passwordPanel -{ - if( !mPasswordPanel ) - { - NSRect box = NSMakeRect( 100, 100, 400, 134 ); - mPasswordPanel = [[NSPanel alloc] initWithContentRect: box - styleMask: NSTitledWindowMask - backing: NSBackingStoreBuffered defer: NO]; - [mPasswordPanel setHidesOnDeactivate: NO]; - [mPasswordPanel setLevel: NSFloatingWindowLevel]; - [mPasswordPanel setTitle: @"GitX SSH Remote Login"]; - if (![mPasswordPanel setFrameUsingName: WINDOWAUTOSAVENAME]) { - [mPasswordPanel center]; - [mPasswordPanel setFrameAutosaveName: WINDOWAUTOSAVENAME]; +@implementation GAPAppDelegate + +-(void)yesNo:(NSString *)prompt url:(NSString *)url{ + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"YES"]; + [alert addButtonWithTitle:@"NO"]; + [alert setMessageText:[NSString stringWithFormat:@"%@?",url]]; + [alert setInformativeText:prompt]; + [alert setAlertStyle:NSWarningAlertStyle]; + NSInteger result = [alert runModal]; + + Boolean yes=NO; + if ( result == NSAlertFirstButtonReturn ) { + yes=YES; + } + [alert release]; + printf("%s",yes?"yes":"no"); +} + + +- (void)pasword:(NSString *)prompt url:(NSString *)url{ + + NSRect box = NSMakeRect(0, 0, 200, 24); + + NSSecureTextField * passView = [[NSSecureTextField alloc] initWithFrame: box]; + [passView setSelectable: YES]; + [passView setEditable: YES]; + [passView setBordered: YES]; + [passView setBezeled: YES]; + [passView setBezelStyle: NSTextFieldSquareBezel]; + [passView selectText: self]; + + + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"Ok"]; + [alert addButtonWithTitle:@"cancel"]; + [alert setMessageText:[NSString stringWithFormat:@"%@?",url]]; + [alert setInformativeText:prompt]; + [alert setAlertStyle:NSWarningAlertStyle]; + [alert setAccessoryView:passView]; + [alert setShowsSuppressionButton:YES]; + [[alert suppressionButton] setTitle:@"Save on keychain"]; + NSInteger result = [alert runModal]; + if ( result == NSAlertFirstButtonReturn ) { + NSString *pas=[passView stringValue]; + printf( "%s", [pas UTF8String] ); + if ([[alert suppressionButton] state] == NSOnState) { + StorePasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding], + [url lengthOfBytesUsingEncoding:NSASCIIStringEncoding], + (void *)[pas cStringUsingEncoding:NSASCIIStringEncoding], + [pas lengthOfBytesUsingEncoding:NSASCIIStringEncoding]); } - - box.origin = NSZeroPoint; // Only need local coords from now on. - - // OK: - NSRect okBox = box; - okBox.origin.x = NSMaxX( box ) -OKBUTTONWIDTH -20; - okBox.size.width = OKBUTTONWIDTH; - okBox.origin.y += 20; - okBox.size.height = OKBUTTONHEIGHT; - NSButton *okButton = [[NSButton alloc] initWithFrame: okBox]; - [okButton setTarget: self]; - [okButton setAction: @selector(doOKButton:)]; - [okButton setTitle: @"OK"]; // +++ Localize. - [okButton setKeyEquivalent: @"\r"]; - [okButton setBordered: YES]; - [okButton setBezelStyle: NSRoundedBezelStyle]; - [[mPasswordPanel contentView] addSubview: okButton]; - - // Cancel: - NSRect cancelBox = box; - cancelBox.origin.x = NSMinX( okBox ) -CANCELBUTTONWIDTH -6; - cancelBox.size.width = CANCELBUTTONWIDTH; - cancelBox.origin.y += 20; - cancelBox.size.height = CANCELBUTTONHEIGHT; - NSButton *cancleButton = [[NSButton alloc] initWithFrame: cancelBox]; - [cancleButton setTarget: self]; - [cancleButton setAction: @selector(doCancelButton:)]; - [cancleButton setTitle: @"Cancel"]; // +++ Localize. - [cancleButton setBordered: YES]; - [cancleButton setBezelStyle: NSRoundedBezelStyle]; - [[mPasswordPanel contentView] addSubview: cancleButton]; - - // Password field: - NSRect passBox = box; - passBox.origin.y = NSMaxY(okBox) + 24; - passBox.size.height = PASSHEIGHT; - passBox.origin.x += 104; - passBox.size.width -= 104 + 20; - mPasswordField = [[NSSecureTextField alloc] initWithFrame: passBox]; - [mPasswordField setSelectable: YES]; - [mPasswordField setEditable: YES]; - [mPasswordField setBordered: YES]; - [mPasswordField setBezeled: YES]; - [mPasswordField setBezelStyle: NSTextFieldSquareBezel]; - [mPasswordField selectText: self]; - [[mPasswordPanel contentView] addSubview: mPasswordField]; - - // Password label: - NSRect passLabelBox = box; - passLabelBox.origin.y = NSMaxY(passBox) + 8; - passLabelBox.size.height = PASSLABELHEIGHT; - passLabelBox.origin.x += 100; - passLabelBox.size.width -= 100 + 20; - NSTextField *passwordLabel = [[NSTextField alloc] initWithFrame: passLabelBox]; - [passwordLabel setSelectable: YES]; - [passwordLabel setEditable: NO]; - [passwordLabel setBordered: NO]; - [passwordLabel setBezeled: NO]; - [passwordLabel setDrawsBackground: NO]; - [passwordLabel setStringValue: @"Please enter your password:"]; // +++ Localize. - [[mPasswordPanel contentView] addSubview: passwordLabel]; - - // GitX icon: - NSRect gitxIconBox = box; - gitxIconBox.origin.y = NSMaxY(box) - 78; - gitxIconBox.size.height = 64; - gitxIconBox.origin.x += 20; - gitxIconBox.size.width = 64; - NSImageView *gitxIconView = [[NSImageView alloc] initWithFrame: gitxIconBox]; - [gitxIconView setEditable: NO]; - NSString *gitxIconPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"gitx.icns"]; - NSImage *gitxIcon = [[NSImage alloc] initWithContentsOfFile: gitxIconPath]; - [gitxIconView setImage: gitxIcon]; - [[mPasswordPanel contentView] addSubview: gitxIconView]; } - return mPasswordPanel; -} - - --(IBAction) doOKButton: (id)sender -{ - printf( "%s\n", [[mPasswordField stringValue] UTF8String] ); - [[NSApplication sharedApplication] stopModalWithCode: 0]; -} - - -// TODO: Need to find out how to get SSH to cancel. -// When the user cancels the window it is opened again for however -// many times the remote server allows failed attempts. --(IBAction) doCancelButton: (id)sender -{ - [[NSApplication sharedApplication] stopModalWithCode: 1]; + [alert release]; } @end +void getproclline(pid_t pid, char *command_name); - -int main( int argc, const char** argv ) +void getproclline(pid_t pid, char *command_name) { - // close stderr to stop cocoa log messages from being picked up by GitX - close(STDERR_FILENO); + int mib[3], argmax, nargs, c = 0; + size_t size; + char *procargs, *sp, *np, *cp; + + mib[0] = CTL_KERN; + mib[1] = KERN_ARGMAX; + + size = sizeof(argmax); + if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) { + return; + } + + /* Allocate space for the arguments. */ + procargs = (char *)malloc(argmax); + if (procargs == NULL) { + return; + } + + mib[0] = CTL_KERN; + mib[1] = KERN_PROCARGS2; + mib[2] = pid; + + size = (size_t)argmax; + if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) { + return; + } + + memcpy(&nargs, procargs, sizeof(nargs)); + cp = procargs + sizeof(nargs); + + /* Skip the saved exec_path. */ + for (; cp < &procargs[size]; cp++) { + if (*cp == '\0') { + /* End of exec_path reached. */ + break; + } + } + if (cp == &procargs[size]) { + return; + } + + /* Skip trailing '\0' characters. */ + for (; cp < &procargs[size]; cp++) { + if (*cp != '\0') { + /* Beginning of first argument reached. */ + break; + } + } + if (cp == &procargs[size]) { + return; + } + /* Save where the argv[0] string starts. */ + sp = cp; + + for (np = NULL; c < nargs && cp < &procargs[size]; cp++) { + if (*cp == '\0') { + c++; + if (np != NULL) { + *np = ' '; + } + np = cp; + } + } + sprintf(command_name, "%s",sp); +} + +OSStatus StorePasswordKeychain (const char *url, UInt32 urlLength, void* password,UInt32 passwordLength) +{ + OSStatus status; + status = SecKeychainAddGenericPassword ( + NULL, // default keychain + 4, // length of service name + "GitX", // service name + urlLength, // length of account name + url, // account name + passwordLength, // length of password + password, // pointer to password data + NULL // the item reference + ); + return (status); +} + +OSStatus GetPasswordKeychain (const char *url, UInt32 urlLength ,void *passwordData,UInt32 *passwordLength, + SecKeychainItemRef *itemRef) +{ + OSStatus status ; + status = SecKeychainFindGenericPassword ( + NULL, // default keychain + 4, // length of service name + "GitX", // service name + urlLength, // length of account name + url, // account name + passwordLength, // length of password + passwordData, // pointer to password data + itemRef // the item reference + ); + return (status); +} + + +int main( int argc, const char* argv[] ) +{ + // close stderr to stop cocoa log messages from being picked up by GitX + close(STDERR_FILENO); - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + ProcessSerialNumber myPSN = { 0, kCurrentProcess }; + TransformProcessType( &myPSN, kProcessTransformToForegroundApplication ); + + NSApplication *app = [NSApplication sharedApplication]; + GAPAppDelegate *appDel = [[GAPAppDelegate alloc] init]; + [app setDelegate: appDel]; - ProcessSerialNumber myPSN = { 0, kCurrentProcess }; - TransformProcessType( &myPSN, kProcessTransformToForegroundApplication ); + + char args[4024]; + getproclline(getppid(),args); + NSString *cmd=[NSString stringWithFormat:@"%@",[NSString stringWithUTF8String:args]]; - NSApplication *app = [NSApplication sharedApplication]; - GAPAppDelegate *appDel = [[GAPAppDelegate alloc] init]; - [app setDelegate: appDel]; - NSWindow *passPanel = [appDel passwordPanel]; + NSLog(@"cmd: '%@'",cmd); - [app activateIgnoringOtherApps: YES]; - [passPanel makeKeyAndOrderFront: nil]; - NSInteger code = [app runModalForWindow: passPanel]; + if([cmd hasPrefix:@"git-remote"]){ + NSArray *args=[cmd componentsSeparatedByString:@" "]; + NSString *url=[args objectAtIndex:[args count]-1]; + + void *passwordData = nil; + SecKeychainItemRef itemRef = nil; + UInt32 passwordLength = 0; + + OSStatus status = GetPasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding],[url lengthOfBytesUsingEncoding:NSASCIIStringEncoding],&passwordData,&passwordLength,&itemRef); + if (status == noErr) { + SecKeychainItemFreeContent (NULL,passwordData); + NSString *pas=[[NSString stringWithCString:passwordData encoding:NSASCIIStringEncoding] substringToIndex:passwordLength]; + printf( "%s", [pas UTF8String] ); + return 0; + } + + NSString *prompt=[NSString stringWithFormat:@"%@",[NSString stringWithCString:argv[1] encoding:NSASCIIStringEncoding]]; + [appDel pasword:prompt url:url]; + }else{ // yes/no? + NSString *prompt=[NSString stringWithFormat:@"%@",[NSString stringWithCString:argv[1] encoding:NSASCIIStringEncoding]]; + NSArray *args=[cmd componentsSeparatedByString:@" "]; + NSString *url=[args objectAtIndex:1]; + [appDel yesNo:prompt url:url]; + } - [defaults synchronize]; - - return code; -} \ No newline at end of file + return 0; +} From 87bc0d8813788236abb9a73970647b9e220434f5 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 27 May 2011 12:14:49 +0200 Subject: [PATCH 38/63] better new git_askpasswd --- gitx_askpasswd_main.m | 77 ++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/gitx_askpasswd_main.m b/gitx_askpasswd_main.m index 75a0a34..6ac156c 100644 --- a/gitx_askpasswd_main.m +++ b/gitx_askpasswd_main.m @@ -29,8 +29,20 @@ #define PASSLABELHEIGHT 16.0 #define WINDOWAUTOSAVENAME @"GitXAskPasswordWindowFrame" +// In 10.6, some NSObject categories (like NSWindowDelegate) were changed to +// protocols. Thus to avoid warnings we need to add protocol specifiers, but +// only when compiling for 10.6+. +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif -@interface GAPAppDelegate : NSObject /**/ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#define PROTOCOL_10_6(...) <__VA_ARGS__> +#else +#define PROTOCOL_10_6(...) +#endif + +@interface GAPAppDelegate : NSObject PROTOCOL_10_6(NSApplicationDelegate) { } @@ -50,7 +62,7 @@ OSStatus StorePasswordKeychain (const char *url, UInt32 urlLength, void* passw [alert setInformativeText:prompt]; [alert setAlertStyle:NSWarningAlertStyle]; NSInteger result = [alert runModal]; - + Boolean yes=NO; if ( result == NSAlertFirstButtonReturn ) { yes=YES; @@ -213,38 +225,49 @@ int main( int argc, const char* argv[] ) NSApplication *app = [NSApplication sharedApplication]; GAPAppDelegate *appDel = [[GAPAppDelegate alloc] init]; - [app setDelegate: appDel]; + [app setDelegate:appDel]; - char args[4024]; - getproclline(getppid(),args); - NSString *cmd=[NSString stringWithFormat:@"%@",[NSString stringWithUTF8String:args]]; + char c_args[4024]; + getproclline(getppid(),c_args); + NSString *cmd=[NSString stringWithFormat:@"%@",[NSString stringWithUTF8String:c_args]]; NSLog(@"cmd: '%@'",cmd); - if([cmd hasPrefix:@"git-remote"]){ - NSArray *args=[cmd componentsSeparatedByString:@" "]; - NSString *url=[args objectAtIndex:[args count]-1]; - - void *passwordData = nil; - SecKeychainItemRef itemRef = nil; - UInt32 passwordLength = 0; - - OSStatus status = GetPasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding],[url lengthOfBytesUsingEncoding:NSASCIIStringEncoding],&passwordData,&passwordLength,&itemRef); - if (status == noErr) { - SecKeychainItemFreeContent (NULL,passwordData); - NSString *pas=[[NSString stringWithCString:passwordData encoding:NSASCIIStringEncoding] substringToIndex:passwordLength]; - printf( "%s", [pas UTF8String] ); - return 0; + NSString *prompt; + NSString *url; + BOOL yesno=NO; + NSArray *args=[cmd componentsSeparatedByString:@" "]; + + if(argc<1){ + prompt=@"Enter your OpenSSH passphrase:"; + url=@"private key"; + }else{ + prompt=[NSString stringWithFormat:@"%@",[NSString stringWithCString:argv[1] encoding:NSASCIIStringEncoding]]; + if([[prompt lowercaseString] rangeOfString:@"yes/no"].location==NSNotFound){ + url=[args objectAtIndex:[args count]-1]; + }else{ + yesno=YES; + url=[args objectAtIndex:1]; } - - NSString *prompt=[NSString stringWithFormat:@"%@",[NSString stringWithCString:argv[1] encoding:NSASCIIStringEncoding]]; - [appDel pasword:prompt url:url]; - }else{ // yes/no? - NSString *prompt=[NSString stringWithFormat:@"%@",[NSString stringWithCString:argv[1] encoding:NSASCIIStringEncoding]]; - NSArray *args=[cmd componentsSeparatedByString:@" "]; - NSString *url=[args objectAtIndex:1]; + } + + void *passwordData = nil; + SecKeychainItemRef itemRef = nil; + UInt32 passwordLength = 0; + + OSStatus status = GetPasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding],[url lengthOfBytesUsingEncoding:NSASCIIStringEncoding],&passwordData,&passwordLength,&itemRef); + if (status == noErr) { + SecKeychainItemFreeContent (NULL,passwordData); + NSString *pas=[[NSString stringWithCString:passwordData encoding:NSASCIIStringEncoding] substringToIndex:passwordLength]; + printf( "%s", [pas UTF8String] ); + return 0; + } + + if(yesno){ [appDel yesNo:prompt url:url]; + }else{ + [appDel pasword:prompt url:url]; } return 0; From 1a35f02ec6d43fad795bf397ea9e262be0a90452 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 3 Jun 2011 15:51:10 -0600 Subject: [PATCH 39/63] rename & add to project --- GitX.xcodeproj/project.pbxproj | 6 +++++ PBGitStashController.m | 24 ------------------- ...ashController.h => PBStashViewController.h | 12 ++++++---- PBStashViewController.m | 23 ++++++++++++++++++ 4 files changed, 37 insertions(+), 28 deletions(-) delete mode 100644 PBGitStashController.m rename PBGitStashController.h => PBStashViewController.h (61%) create mode 100644 PBStashViewController.m diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 7cb0c81..fc0c36e 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -138,6 +138,7 @@ D8FDDA6F114335E8005647F6 /* PBGitSVStageItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA67114335E8005647F6 /* PBGitSVStageItem.m */; }; D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; }; D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; }; + DDB8FE0113998CE2001A9EE2 /* PBStashViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */; }; F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; }; F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; }; F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; }; @@ -425,6 +426,8 @@ D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVTagItem.m; sourceTree = ""; }; D8FDDA7311433634005647F6 /* PBSourceViewItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItems.h; sourceTree = ""; }; D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = ""; }; + DDB8FDFF13998CE2001A9EE2 /* PBStashViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashViewController.h; sourceTree = ""; }; + DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashViewController.m; sourceTree = ""; }; F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = ""; }; F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = ""; }; F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = ""; }; @@ -939,6 +942,8 @@ 77C8280C06725ACE000B614F /* ApplicationController.m */, 93CB42C00EAB7B2200530609 /* PBGitDefaults.h */, 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */, + DDB8FDFF13998CE2001A9EE2 /* PBStashViewController.h */, + DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */, F57CC43F0E05E496000472E2 /* PBGitWindowController.h */, F57CC4400E05E496000472E2 /* PBGitWindowController.m */, 911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */, @@ -1447,6 +1452,7 @@ 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, 31776089133569350025876E /* SearchWebView.m in Sources */, + DDB8FE0113998CE2001A9EE2 /* PBStashViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBGitStashController.m b/PBGitStashController.m deleted file mode 100644 index 8be1d96..0000000 --- a/PBGitStashController.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// PBGitHistoryView.h -// GitX -// -// Created by David Catmull on 20-06-11. -// Copyright 2011. All rights reserved. -// - -#import "PBGitStashController.h" - -@implementation PBGitStashController - - -- (void) awakeFromNib -{ -} - -- (void) showStash:(PBGitStash)stash -{ - // git stash show -p [stash stashSourceMessage] - [webController -} - -@end diff --git a/PBGitStashController.h b/PBStashViewController.h similarity index 61% rename from PBGitStashController.h rename to PBStashViewController.h index 0f04e3a..ca8b334 100644 --- a/PBGitStashController.h +++ b/PBStashViewController.h @@ -1,5 +1,5 @@ // -// PBGitHistoryView.h +// PBStashViewController.h // GitX // // Created by David Catmull on 20-06-11. @@ -7,14 +7,18 @@ // #import "PBViewController.h" +#import "PBWebController.h" + +@class PBGitStash; +@class PBWebStashController; // Controls the view displaying a stash diff -@interface PBGitStashController : PBViewController { +@interface PBStashViewController : PBViewController { IBOutlet id webView; - IBOutlet PBWebStashController *webHistoryController; + IBOutlet PBWebStashController *webController; } -- (void) c:(PBGitStash)stash; +- (void) showStash:(PBGitStash*)stash; @end diff --git a/PBStashViewController.m b/PBStashViewController.m new file mode 100644 index 0000000..e29b746 --- /dev/null +++ b/PBStashViewController.m @@ -0,0 +1,23 @@ +// +// PBStashViewController.h +// GitX +// +// Created by David Catmull on 20-06-11. +// Copyright 2011. All rights reserved. +// + +#import "PBStashViewController.h" +#import "PBGitStash.h" + +@implementation PBStashViewController + +- (void) awakeFromNib +{ +} + +- (void) showStash:(PBGitStash*)stash +{ + [webController changeContentTo:stash]; +} + +@end From f2d875705ec3c2417a0c58c64db91e10f63e0e5a Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 3 Jun 2011 16:41:50 -0600 Subject: [PATCH 40/63] rename again to accommodate implicit nib naming --- GitX.xcodeproj/project.pbxproj | 12 ++++++------ ...ashViewController.h => PBStashContentController.h | 4 ++-- ...ashViewController.m => PBStashContentController.m | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) rename PBStashViewController.h => PBStashContentController.h (86%) rename PBStashViewController.m => PBStashContentController.m (69%) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index fc0c36e..0617280 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -138,7 +138,7 @@ D8FDDA6F114335E8005647F6 /* PBGitSVStageItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA67114335E8005647F6 /* PBGitSVStageItem.m */; }; D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; }; D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; }; - DDB8FE0113998CE2001A9EE2 /* PBStashViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */; }; + DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */; }; F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; }; F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; }; F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; }; @@ -426,8 +426,8 @@ D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVTagItem.m; sourceTree = ""; }; D8FDDA7311433634005647F6 /* PBSourceViewItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItems.h; sourceTree = ""; }; D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = ""; }; - DDB8FDFF13998CE2001A9EE2 /* PBStashViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashViewController.h; sourceTree = ""; }; - DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashViewController.m; sourceTree = ""; }; + DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashContentController.h; sourceTree = ""; }; + DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashContentController.m; sourceTree = ""; }; F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = ""; }; F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = ""; }; F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = ""; }; @@ -942,8 +942,8 @@ 77C8280C06725ACE000B614F /* ApplicationController.m */, 93CB42C00EAB7B2200530609 /* PBGitDefaults.h */, 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */, - DDB8FDFF13998CE2001A9EE2 /* PBStashViewController.h */, - DDB8FE0013998CE2001A9EE2 /* PBStashViewController.m */, + DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */, + DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */, F57CC43F0E05E496000472E2 /* PBGitWindowController.h */, F57CC4400E05E496000472E2 /* PBGitWindowController.m */, 911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */, @@ -1452,7 +1452,7 @@ 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, 31776089133569350025876E /* SearchWebView.m in Sources */, - DDB8FE0113998CE2001A9EE2 /* PBStashViewController.m in Sources */, + DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBStashViewController.h b/PBStashContentController.h similarity index 86% rename from PBStashViewController.h rename to PBStashContentController.h index ca8b334..f048bac 100644 --- a/PBStashViewController.h +++ b/PBStashContentController.h @@ -1,5 +1,5 @@ // -// PBStashViewController.h +// PBStashContentController.h // GitX // // Created by David Catmull on 20-06-11. @@ -13,7 +13,7 @@ @class PBWebStashController; // Controls the view displaying a stash diff -@interface PBStashViewController : PBViewController { +@interface PBStashContentController : PBViewController { IBOutlet id webView; IBOutlet PBWebStashController *webController; } diff --git a/PBStashViewController.m b/PBStashContentController.m similarity index 69% rename from PBStashViewController.m rename to PBStashContentController.m index e29b746..b2a7a11 100644 --- a/PBStashViewController.m +++ b/PBStashContentController.m @@ -1,15 +1,15 @@ // -// PBStashViewController.h +// PBStashContentController.h // GitX // // Created by David Catmull on 20-06-11. // Copyright 2011. All rights reserved. // -#import "PBStashViewController.h" +#import "PBStashContentController.h" #import "PBGitStash.h" -@implementation PBStashViewController +@implementation PBStashContentController - (void) awakeFromNib { From 94c08dd5bce27d37650f5ac217e51a083bb935d6 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 3 Jun 2011 16:51:42 -0600 Subject: [PATCH 41/63] stash view xib --- GitX.xcodeproj/project.pbxproj | 4 + PBStashContentView.xib | 1120 ++++++++++++++++++++++++++++++++ 2 files changed, 1124 insertions(+) create mode 100644 PBStashContentView.xib diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 0617280..cf4a4af 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -139,6 +139,7 @@ D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; }; D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; }; DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */; }; + DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */; }; F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; }; F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; }; F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; }; @@ -428,6 +429,7 @@ D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = ""; }; DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashContentController.h; sourceTree = ""; }; DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashContentController.m; sourceTree = ""; }; + DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBStashContentView.xib; sourceTree = ""; }; F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = ""; }; F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = ""; }; F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = ""; }; @@ -768,6 +770,7 @@ F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */, F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */, F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */, + DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */, D85B939210E3D8B4007F3C28 /* PBCreateBranchSheet.xib */, D889EB3010E6BCBB00F08413 /* PBCreateTagSheet.xib */, D8C1B77110E875CF009B7F8B /* PBRemoteProgressSheet.xib */, @@ -1291,6 +1294,7 @@ 316E7202131EE9C600AFBB36 /* list_Template.png in Resources */, 316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */, 65D58BC4132D27A8003F7290 /* PBResetSheet.xib in Resources */, + DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBStashContentView.xib b/PBStashContentView.xib new file mode 100644 index 0000000..2015956 --- /dev/null +++ b/PBStashContentView.xib @@ -0,0 +1,1120 @@ + + + + 1060 + 10J869 + 851 + 1038.35 + 461.00 + + YES + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + 851 + 851 + + + + YES + + + + YES + com.apple.WebKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + PBStashContentController + + + FirstResponder + + + NSApplication + + + + 274 + + YES + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {480, 272} + + + + + + + + YES + + YES + WebKitDefaultFixedFontSize + WebKitDefaultFontSize + WebKitMinimumFontSize + + + YES + + + + + + + YES + YES + + + {480, 272} + + NSView + + + PBWebStashController + + + + + YES + + + view + + + + 4 + + + + frameLoadDelegate + + + + 5 + + + + policyDelegate + + + + 6 + + + + UIDelegate + + + + 7 + + + + webController + + + + 8 + + + + view + + + + 9 + + + + webView + + + + 10 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + Stash + + + 2 + + + + + 3 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 2.IBPluginDependency + 2.IBViewBoundsToFrameTransform + 3.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{14, 862}, {480, 272}} + com.apple.InterfaceBuilder.CocoaPlugin + {628, 654} + {{357, 416}, {480, 272}} + com.apple.WebKitIBPlugin + + AUJwAABCFAAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 10 + + + + YES + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + + + PBGitRepository + NSDocument + + IBProjectSource + PBGitRepository.h + + + + PBStashContentController + PBViewController + + YES + + YES + webController + webView + + + YES + PBWebStashController + id + + + + YES + + YES + webController + webView + + + YES + + webController + PBWebStashController + + + webView + id + + + + + IBProjectSource + PBStashContentController.h + + + + PBViewController + NSViewController + + refresh: + id + + + refresh: + + refresh: + id + + + + IBProjectSource + PBViewController.h + + + + PBWebController + NSObject + + YES + + YES + repository + view + + + YES + PBGitRepository + WebView + + + + YES + + YES + repository + view + + + YES + + repository + PBGitRepository + + + view + WebView + + + + + IBProjectSource + PBWebController.h + + + + PBWebStashController + PBWebController + + + + WebView + + updateSearch: + NSSearchField + + + updateSearch: + + updateSearch: + NSSearchField + + + + IBProjectSource + SearchWebView.h + + + + + YES + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSDocument + NSObject + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + id + id + id + id + id + id + + + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + + IBFrameworkSource + AppKit.framework/Headers/NSDocument.h + + + + NSDocument + + IBFrameworkSource + AppKit.framework/Headers/NSDocumentScripting.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUAppcast.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUUpdater.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebDownload.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebEditingDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebFrameLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebJavaPlugIn.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPlugin.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPluginContainer.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPolicyDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebResourceLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebScriptObject.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebUIDelegate.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSSearchField + NSTextField + + IBFrameworkSource + AppKit.framework/Headers/NSSearchField.h + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSViewController + NSResponder + + view + NSView + + + view + + view + NSView + + + + IBFrameworkSource + AppKit.framework/Headers/NSViewController.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSWindow + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + WebView + NSView + + YES + + YES + goBack: + goForward: + makeTextLarger: + makeTextSmaller: + makeTextStandardSize: + reload: + reloadFromOrigin: + stopLoading: + takeStringURLFrom: + toggleContinuousSpellChecking: + toggleSmartInsertDelete: + + + YES + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + goBack: + goForward: + makeTextLarger: + makeTextSmaller: + makeTextStandardSize: + reload: + reloadFromOrigin: + stopLoading: + takeStringURLFrom: + toggleContinuousSpellChecking: + toggleSmartInsertDelete: + + + YES + + goBack: + id + + + goForward: + id + + + makeTextLarger: + id + + + makeTextSmaller: + id + + + makeTextStandardSize: + id + + + reload: + id + + + reloadFromOrigin: + id + + + stopLoading: + id + + + takeStringURLFrom: + id + + + toggleContinuousSpellChecking: + id + + + toggleSmartInsertDelete: + id + + + + + IBFrameworkSource + WebKit.framework/Headers/WebView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + GitX.xcodeproj + 3 + + From e1836bb02ae8b6fde282d78ce441b523649cc283 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 3 Jun 2011 17:38:05 -0600 Subject: [PATCH 42/63] plug the stuff in, not working yet --- PBGitSidebarController.h | 3 +++ PBGitSidebarController.m | 9 +++++++++ PBStashContentController.h | 11 +++-------- PBStashContentController.m | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index 59b9b9d..a2eb106 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -12,6 +12,7 @@ @class PBSourceViewItem; @class PBGitHistoryController; @class PBGitCommitController; +@class PBStashContentController; @interface PBGitSidebarController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate, NSMenuDelegate){ IBOutlet NSWindow *window; @@ -33,6 +34,7 @@ PBGitHistoryController *historyViewController; PBGitCommitController *commitViewController; + PBStashContentController *stashViewController; } - (void) selectStage; @@ -54,5 +56,6 @@ @property(readonly) NSView *sourceListControlsView; @property(readonly) PBGitHistoryController *historyViewController; @property(readonly) PBGitCommitController *commitViewController; +@property(readonly) PBStashContentController *stashViewController; @end diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index bb84afa..28d8fb0 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -24,6 +24,7 @@ #import "PBGitStash.h" #import "PBGitSubmodule.h" #import "PBSubmoduleController.h" +#import "PBStashContentController.h" static NSString * const kObservingContextStashes = @"stashesChanged"; static NSString * const kObservingContextSubmodules = @"submodulesChanged"; @@ -43,6 +44,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; @synthesize sourceListControlsView; @synthesize historyViewController; @synthesize commitViewController; +@synthesize stashViewController; - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller { @@ -61,6 +63,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController]; commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController]; + stashViewController = [[PBStashContentController alloc] initWithRepository:repository superController:superController]; [repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"]; [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"]; @@ -319,6 +322,12 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; [PBGitDefaults setShowStageView:YES]; } + if ([item parent] == stashes) { + [superController changeContentController:stashViewController]; + [PBGitDefaults setShowStageView:NO]; + [stashViewController showStash:(PBGitStash*)[(PBGitMenuItem*)item sourceObject]]; + } + [self updateActionMenu]; [self updateRemoteControls]; } diff --git a/PBStashContentController.h b/PBStashContentController.h index f048bac..6254632 100644 --- a/PBStashContentController.h +++ b/PBStashContentController.h @@ -7,7 +7,7 @@ // #import "PBViewController.h" -#import "PBWebController.h" +#import "PBWebHistoryController.h" @class PBGitStash; @class PBWebStashController; @@ -22,13 +22,8 @@ @end -@interface PBWebStashController : PBWebController { - PBGitStash* currentStash; - NSString* diff; +// TODO: This class may not be needed +@interface PBWebStashController : PBWebHistoryController { } -- (void) changeContentTo:(PBGitStash*)stash; - -@property (readonly) NSString* diff; - @end diff --git a/PBStashContentController.m b/PBStashContentController.m index b2a7a11..27d2175 100644 --- a/PBStashContentController.m +++ b/PBStashContentController.m @@ -7,17 +7,50 @@ // #import "PBStashContentController.h" +#import "PBGitDefaults.h" #import "PBGitStash.h" @implementation PBStashContentController - (void) awakeFromNib { + [webController setRepository:repository]; } - (void) showStash:(PBGitStash*)stash { - [webController changeContentTo:stash]; + NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]]; + NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]]; + PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha]; + + [webController changeContentTo:commit]; } @end + +@implementation PBWebStashController +/* +- (void) changeContentTo:(PBGitStash*)stash +{ + if (stash == nil || !finishedLoading) + return; + + currentStash = stash; + + // TODO: get the stash's SHA and put it in currentSha + + NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]]; + NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", stashRef, nil]; + + if (![PBGitDefaults showWhitespaceDifferences]) + [taskArguments insertObject:@"-w" atIndex:1]; + + NSFileHandle *handle = [repository handleForArguments:taskArguments]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + [nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; + [nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; + [handle readToEndOfFileInBackgroundAndNotify]; +} +*/ +@end From 800a143b048ccfb6aaa49228fd173d17742ca872 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sun, 5 Jun 2011 17:11:53 -0600 Subject: [PATCH 43/63] modernize loop --- PBWebHistoryController.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 5d1bd47..70bdb7a 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -88,9 +88,7 @@ NSArray *refsA=[historyController.webCommit refs]; NSString *currentRef=[[[historyController repository] headRef] simpleRef]; NSString *style=@""; - int r=0; - for(r=0;r<[refsA count];r++){ - PBGitRef *ref=[refsA objectAtIndex:r]; + for(PBGitRef *ref in refsA){ if([currentRef isEqualToString:[ref ref]]){ style=[NSString stringWithFormat:@"currentBranch refs %@",[ref type]]; }else{ From 50388f57eb565accdc0527e9c986390304162947 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sun, 5 Jun 2011 17:16:55 -0600 Subject: [PATCH 44/63] add some spaces --- PBWebHistoryController.m | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 70bdb7a..cbf52ea 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -84,43 +84,43 @@ return; - NSMutableString *refs=[NSMutableString string]; - NSArray *refsA=[historyController.webCommit refs]; - NSString *currentRef=[[[historyController repository] headRef] simpleRef]; - NSString *style=@""; + NSMutableString *refs = [NSMutableString string]; + NSArray *refsA = [historyController.webCommit refs]; + NSString *currentRef = [[[historyController repository] headRef] simpleRef]; + NSString *style = @""; for(PBGitRef *ref in refsA){ if([currentRef isEqualToString:[ref ref]]){ - style=[NSString stringWithFormat:@"currentBranch refs %@",[ref type]]; + style = [NSString stringWithFormat:@"currentBranch refs %@",[ref type]]; }else{ - style=[NSString stringWithFormat:@"refs %@",[ref type]]; + style = [NSString stringWithFormat:@"refs %@",[ref type]]; } [refs appendString:[NSString stringWithFormat:@"%@",style,[ref shortName]]]; } // Header - NSString *header=[self parseHeader:details withRefs:refs]; + NSString *header = [self parseHeader:details withRefs:refs]; // File Stats - NSMutableDictionary *stats=[self parseStats:details]; + NSMutableDictionary *stats = [self parseStats:details]; // File list - NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; - NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats]; + NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; - NSString *diffs=[GLFileView parseDiff:d]; + NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *diffs = [GLFileView parseDiff:d]; - NSString *html=[NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; + NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; + html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; + html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; #ifdef DEBUG_BUILD - NSString *dom=[(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; - NSString *tmpFile=@"~/tmp/test2.html"; + NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; + NSString *tmpFile = @"~/tmp/test2.html"; [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; #endif } From a2c623bc2cbc6c605826458dbd8aa0b1c145163d Mon Sep 17 00:00:00 2001 From: David Catmull Date: Wed, 8 Jun 2011 15:13:17 -0600 Subject: [PATCH 45/63] delete PBWebStashController --- PBStashContentController.h | 8 +- PBStashContentController.m | 27 ----- PBStashContentView.xib | 199 +++++++++++++++++++++++++++++++++++-- 3 files changed, 194 insertions(+), 40 deletions(-) diff --git a/PBStashContentController.h b/PBStashContentController.h index 6254632..3ec6061 100644 --- a/PBStashContentController.h +++ b/PBStashContentController.h @@ -15,15 +15,9 @@ // Controls the view displaying a stash diff @interface PBStashContentController : PBViewController { IBOutlet id webView; - IBOutlet PBWebStashController *webController; + IBOutlet PBWebHistoryController *webController; } - (void) showStash:(PBGitStash*)stash; @end - -// TODO: This class may not be needed -@interface PBWebStashController : PBWebHistoryController { -} - -@end diff --git a/PBStashContentController.m b/PBStashContentController.m index 27d2175..8432872 100644 --- a/PBStashContentController.m +++ b/PBStashContentController.m @@ -27,30 +27,3 @@ } @end - -@implementation PBWebStashController -/* -- (void) changeContentTo:(PBGitStash*)stash -{ - if (stash == nil || !finishedLoading) - return; - - currentStash = stash; - - // TODO: get the stash's SHA and put it in currentSha - - NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]]; - NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", stashRef, nil]; - - if (![PBGitDefaults showWhitespaceDifferences]) - [taskArguments insertObject:@"-w" atIndex:1]; - - NSFileHandle *handle = [repository handleForArguments:taskArguments]; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - [nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; - [nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; - [handle readToEndOfFileInBackgroundAndNotify]; -} -*/ -@end diff --git a/PBStashContentView.xib b/PBStashContentView.xib index 2015956..5dfb786 100644 --- a/PBStashContentView.xib +++ b/PBStashContentView.xib @@ -109,7 +109,7 @@ NSView
- PBWebStashController + PBWebHistoryController
@@ -280,6 +280,158 @@ NSApplication+GitXScripting.h
+ + PBGitHistoryController + PBViewController + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openFilesAction: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + showCommitsFromTree: + showInFinderAction: + toggleQLPreviewPanel: + updateSearch: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openFilesAction: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + showCommitsFromTree: + showInFinderAction: + toggleQLPreviewPanel: + updateSearch: + + + YES + + cherryPick: + id + + + createBranch: + id + + + createTag: + id + + + merge: + id + + + openFilesAction: + id + + + openSelectedFile: + id + + + rebase: + id + + + refresh: + id + + + selectNext: + id + + + selectPrevious: + id + + + setBranchFilter: + id + + + setDetailedView: + id + + + setTreeView: + id + + + showAddRemoteSheet: + id + + + showCommitsFromTree: + id + + + showInFinderAction: + id + + + toggleQLPreviewPanel: + id + + + updateSearch: + id + + + + + IBProjectSource + PBGitHistoryController.h + + PBGitRepository NSDocument @@ -300,7 +452,7 @@ YES - PBWebStashController + PBWebHistoryController id
@@ -315,7 +467,7 @@ YES webController - PBWebStashController + PBWebHistoryController webView @@ -323,7 +475,7 @@
- + IBProjectSource PBStashContentController.h @@ -388,9 +540,44 @@
- PBWebStashController + PBWebHistoryController PBWebController - + + YES + + YES + contextMenuDelegate + historyController + + + YES + id + PBGitHistoryController + + + + YES + + YES + contextMenuDelegate + historyController + + + YES + + contextMenuDelegate + id + + + historyController + PBGitHistoryController + + + + + IBProjectSource + PBWebHistoryController.h + WebView From e254a4488faeb8933eeef0b946788515ef2d75c4 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Wed, 8 Jun 2011 16:06:49 -0600 Subject: [PATCH 46/63] fix some tabs --- PBGitHistoryController.h | 2 +- PBGitHistoryController.m | 4 ++-- PBGitSidebarController.m | 2 +- PBWebHistoryController.m | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 840d8c4..228e2a2 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -33,7 +33,7 @@ IBOutlet PBCommitList* commitList; IBOutlet NSSplitView *historySplitView; IBOutlet PBWebHistoryController *webHistoryController; - QLPreviewPanel* previewPanel; + QLPreviewPanel* previewPanel; IBOutlet PBHistorySearchController *searchController; IBOutlet GLFileView *fileView; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 4d1a787..64630e1 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -94,7 +94,7 @@ [super awakeFromNib]; - [fileBrowser setDelegate:self]; + [fileBrowser setDelegate:self]; } - (void)updateKeys @@ -414,7 +414,7 @@ - (void) updateView { - [self refresh: nil]; + [self refresh: nil]; [self updateKeys]; } diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 28d8fb0..63290d6 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -325,7 +325,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; if ([item parent] == stashes) { [superController changeContentController:stashViewController]; [PBGitDefaults setShowStageView:NO]; - [stashViewController showStash:(PBGitStash*)[(PBGitMenuItem*)item sourceObject]]; + [stashViewController showStash:(PBGitStash*)[(PBGitMenuItem*)item sourceObject]]; } [self updateActionMenu]; diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index cbf52ea..f8ccead 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -39,7 +39,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if ([(NSString *)context isEqualToString: @"ChangedCommit"]) + if ([(NSString *)context isEqualToString: @"ChangedCommit"]) [self changeContentTo: historyController.webCommit]; else [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; From 0d89d91d00bd310347912765c8315413f968b895 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Wed, 8 Jun 2011 16:35:46 -0600 Subject: [PATCH 47/63] fix initial stash load --- PBGitSidebarController.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 63290d6..14dd91d 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -65,6 +65,8 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController]; stashViewController = [[PBStashContentController alloc] initWithRepository:repository superController:superController]; + [stashViewController loadView]; + [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"]; @@ -87,6 +89,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; { [historyViewController closeView]; [commitViewController closeView]; + [stashViewController closeView]; [repository removeObserver:self forKeyPath:@"currentBranch"]; [repository removeObserver:self forKeyPath:@"branches"]; From 0da73789eba4e699ad7aa3987cfbf160b7e2adb8 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 10 Jun 2011 17:12:50 -0600 Subject: [PATCH 48/63] saner method name --- PBWebHistoryController.h | 4 ++-- PBWebHistoryController.m | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index f7a7cf8..a692aad 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -1,5 +1,5 @@ // -// PBWebGitController.h +// PBWebHistoryController.h // GitTest // // Created by Pieter de Bie on 14-06-08. @@ -28,7 +28,7 @@ - (void) sendKey: (NSString*) key; - (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges; - (NSMutableDictionary *)parseStats:(NSString *)txt; -- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat; +- (NSString *) arbitraryHashForString:(NSString*)concat; - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; @property (readonly) NSString* diff; diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index f8ccead..85599f8 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -1,5 +1,5 @@ // -// PBWebGitController.m +// PBWebHistoryController.m // GitTest // // Created by Pieter de Bie on 14-06-08. @@ -189,7 +189,7 @@ if(![email isEqualToString:last_mail]){ [auths appendString:[NSString stringWithFormat:@"
",rol]]; if([self isFeatureEnabled:@"gravatar"]){ - NSString *hash=[self someMethodThatReturnsSomeHashForSomeString:email]; + NSString *hash=[self arbitraryHashForString:email]; [auths appendString:[NSString stringWithFormat:@"",hash]]; } [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; @@ -204,7 +204,7 @@ return [NSString stringWithFormat:@"",refs,subject,auths,badges]; } -- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat { +- (NSString *) arbitraryHashForString:(NSString*)concat { const char *concat_str = [concat UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(concat_str, strlen(concat_str), result); From 9f983766ddd00b3e3ba49668683653ae7c956301 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 10 Jun 2011 17:35:31 -0600 Subject: [PATCH 49/63] start on refactoring PBWebHistoryController --- PBWebCommitController.h | 31 +++++ PBWebCommitController.m | 286 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 PBWebCommitController.h create mode 100644 PBWebCommitController.m diff --git a/PBWebCommitController.h b/PBWebCommitController.h new file mode 100644 index 0000000..0cd4af4 --- /dev/null +++ b/PBWebCommitController.h @@ -0,0 +1,31 @@ +// +// PBWebCommitController.h +// +// Created by David Catmull on 10-06-11. +// + +#import +#import "PBWebController.h" + +#import "PBRefContextDelegate.h" + + +@class NSString; +@class PBGitCommit; + +@interface PBWebCommitController : PBWebController { + IBOutlet id contextMenuDelegate; + + NSString* currentSha; + NSString* diff; +} + +- (void) changeContentTo: (PBGitCommit *) content; +- (void) sendKey: (NSString*) key; +- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges; +- (NSMutableDictionary *)parseStats:(NSString *)txt; +- (NSString *) arbitraryHashForString:(NSString*)concat; +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; + +@property (readonly) NSString* diff; +@end diff --git a/PBWebCommitController.m b/PBWebCommitController.m new file mode 100644 index 0000000..cb955db --- /dev/null +++ b/PBWebCommitController.m @@ -0,0 +1,286 @@ +// +// PBWebCommitController.m +// +// Created by David Catmull on 10-06-11. +// + +#import "PBWebCommitController.h" +#import "PBGitCommit.h" +#import "PBGitDefaults.h" +#import "GLFileView.h" +#import + +@implementation PBWebCommitController + +@synthesize diff; + +- (void) awakeFromNib +{ + startFile = @"history"; + [super awakeFromNib]; +} + +- (void)closeView +{ + [[self script] setValue:nil forKey:@"commit"]; + + [super closeView]; +} + +- (void) didLoad +{ + currentSha = nil; +} + +- (void) changeContentTo: (PBGitCommit *) content +{ + if (content == nil || !finishedLoading) + return; + + currentSha = [content sha]; + + // Now we load the extended details. We used to do this in a separate thread, + // but this caused some funny behaviour because NSTask's and NSThread's don't really + // like each other. Instead, just do it async. + + NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil]; + if (![PBGitDefaults showWhitespaceDifferences]) + [taskArguments insertObject:@"-w" atIndex:1]; + + NSFileHandle *handle = [repository handleForArguments:taskArguments]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + // Remove notification, in case we have another one running + [nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; + [nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; + [handle readToEndOfFileInBackgroundAndNotify]; +} + +- (void)commitDetailsLoaded:(NSNotification *)notification +{ + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; + + NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem]; + if (!data) + return; + + NSString *details = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + if (!details) + details = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding]; + + if (!details) + return; + + // Header + NSString *header = [self parseHeader:details withRefs:[self refsForCurrentCommit]]; + + // File Stats + NSMutableDictionary *stats = [self parseStats:details]; + + // File list + NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; + + // Diffs list + NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *diffs = [GLFileView parseDiff:d]; + + NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; + + html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; + html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; + + [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; + +#ifdef DEBUG_BUILD + NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; + NSString *tmpFile = @"~/tmp/test2.html"; + [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; +#endif +} + +- (NSString*) refsForCurrentCommit +{ + return @""; +} + +- (NSMutableDictionary *)parseStats:(NSString *)txt +{ + NSArray *lines = [txt componentsSeparatedByString:@"\n"]; + NSMutableDictionary *stats=[NSMutableDictionary dictionary]; + int black=0; + for(NSString *line in lines){ + if([line length]==0){ + black++; + }else if(black==2){ + NSArray *file=[line componentsSeparatedByString:@"\t"]; + if([file count]==3){ + [stats setObject:file forKey:[file objectAtIndex:2]]; + } + } + } + return stats; +} + +- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges +{ + NSArray *lines = [txt componentsSeparatedByString:@"\n"]; + NSString *line; + NSString *last_mail=@""; + NSMutableString *auths=[NSMutableString string]; + NSMutableString *refs=[NSMutableString string]; + NSMutableString *subject=[NSMutableString string]; + BOOL subj=FALSE; + + int i; + for (i=0; i<[lines count]; i++) { + line=[lines objectAtIndex:i]; + if([line length]==0){ + if(!subj){ + subj=TRUE; + }else{ + i=[lines count]; + } + }else{ + if (subj) { + NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + [subject appendString:[NSString stringWithFormat:@"%@
",[GLFileView escapeHTML:trimmedLine]]]; + }else{ + NSArray *comps=[line componentsSeparatedByString:@" "]; + if([comps count]==2){ + [refs appendString:[NSString stringWithFormat:@"%@%@",[comps objectAtIndex:0],[comps objectAtIndex:1]]]; + }else if([comps count]>2){ + NSRange r_email_i = [line rangeOfString:@"<"]; + NSRange r_email_e = [line rangeOfString:@">"]; + NSRange r_name_i = [line rangeOfString:@" "]; + + NSString *rol=[line substringToIndex:r_name_i.location]; + NSString *name=[line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))]; + NSString *email=[line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))]; + + NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "]; + NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]]; + NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init]; + [theDateFormatter setDateStyle:NSDateFormatterMediumStyle]; + [theDateFormatter setTimeStyle:NSDateFormatterMediumStyle]; + NSString *dateString=[theDateFormatter stringForObjectValue:date]; + + if(![email isEqualToString:last_mail]){ + [auths appendString:[NSString stringWithFormat:@"
",rol]]; + if([self isFeatureEnabled:@"gravatar"]){ + NSString *hash=[self arbitraryHashForString:email]; + [auths appendString:[NSString stringWithFormat:@"",hash]]; + } + [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; + [auths appendString:[NSString stringWithFormat:@"

%@

",dateString]]; + } + last_mail=email; + } + } + } + } + + return [NSString stringWithFormat:@"",refs,subject,auths,badges]; +} + +- (NSString *) arbitraryHashForString:(NSString*)concat { + const char *concat_str = [concat UTF8String]; + unsigned char result[CC_MD5_DIGEST_LENGTH]; + CC_MD5(concat_str, strlen(concat_str), result); + + NSMutableString *hash = [NSMutableString string]; + + int i; + for (i = 0; i < 16; i++) + [hash appendFormat:@"%02x", result[i]]; + + return hash; +} + +- (void)selectCommit:(NSString *)sha +{ +} + +// TODO: need to be refactoring +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2 +{ + NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil]; + [repository handleInWorkDirForArguments:args]; +} + + +- (void) sendKey: (NSString*) key +{ + id script = [view windowScriptObject]; + [script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]]; +} + +- (void) copySource +{ + NSString *source = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; + NSPasteboard *a =[NSPasteboard generalPasteboard]; + [a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; + [a setString:source forType: NSStringPboardType]; +} + +- (NSArray *) webView:(WebView *)sender +contextMenuItemsForElement:(NSDictionary *)element + defaultMenuItems:(NSArray *)defaultMenuItems +{ + DOMNode *node = [element valueForKey:@"WebElementDOMNode"]; + + while (node) { + // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref. + if ([[node className] hasPrefix:@"refs "]) { + NSString *selectedRefString = [[[node childNodes] item:0] textContent]; + for (PBGitRef *ref in historyController.webCommit.refs) + { + if ([[ref shortName] isEqualToString:selectedRefString]) + return [contextMenuDelegate menuItemsForRef:ref]; + } + DLog(@"Could not find selected ref!"); + return defaultMenuItems; + } + if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) + return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]]; + else if ([[node class] isEqual:[DOMHTMLImageElement class]]) { + // Copy Image is the only menu item that makes sense here since we don't need + // to download the image or open it in a new window (besides with the + // current implementation these two entries can crash GitX anyway) + for (NSMenuItem *item in defaultMenuItems) + if ([item tag] == WebMenuItemTagCopyImageToClipboard) + return [NSArray arrayWithObject:item]; + return nil; + } + + node = [node parentNode]; + } + + return defaultMenuItems; +} + + +// Open external links in the default browser +- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation + request:(NSURLRequest *)request + newFrameName:(NSString *)frameName + decisionListener:(id < WebPolicyDecisionListener >)listener +{ + [[NSWorkspace sharedWorkspace] openURL:[request URL]]; +} + +- getConfig:(NSString *)config +{ + return [repository valueForKeyPath:[@"config." stringByAppendingString:config]]; +} + +- (void)finalize +{ + [super finalize]; +} + +- (void) preferencesChanged +{ + [[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil]; +} + +@end From 91026f857e606e96d9f686491660f6b38049c8ee Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sat, 11 Jun 2011 15:06:11 -0600 Subject: [PATCH 50/63] base PBWebHistoryController on PBWebCommitController --- GitX.xcodeproj/project.pbxproj | 6 + PBStashContentController.m | 1 + PBWebCommitController.h | 8 +- PBWebCommitController.m | 31 ++-- PBWebHistoryController.h | 21 +-- PBWebHistoryController.m | 250 ++------------------------------- 6 files changed, 45 insertions(+), 272 deletions(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index cf4a4af..6d96bab 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D58BC6132D48C0003F7290 /* PBResetSheet.m */; }; 770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; }; 77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; }; + 89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89087CA513A3E46B00911503 /* PBWebCommitController.m */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; @@ -335,6 +336,8 @@ 77C82804067257F0000B614F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; 77C8280B06725ACE000B614F /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = ""; }; 77C8280C06725ACE000B614F /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = ""; }; + 89087CA413A3E46500911503 /* PBWebCommitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebCommitController.h; sourceTree = ""; }; + 89087CA513A3E46B00911503 /* PBWebCommitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebCommitController.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* GitX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitX.app; sourceTree = BUILT_PRODUCTS_DIR; }; 911111E10E58BD5A00BF76B4 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/RepositoryWindow.xib; sourceTree = ""; }; @@ -953,6 +956,8 @@ 911111F70E594F3F00BF76B4 /* PBRepositoryDocumentController.m */, F5E926040E8827D300056E75 /* PBViewController.h */, F5E926050E8827D300056E75 /* PBViewController.m */, + 89087CA413A3E46500911503 /* PBWebCommitController.h */, + 89087CA513A3E46B00911503 /* PBWebCommitController.m */, F5EF8C8C0E9D4A5D0050906B /* PBWebController.h */, F5EF8C8D0E9D4A5D0050906B /* PBWebController.m */, F5FE6C010EB13BC900F30D12 /* PBServicesController.h */, @@ -1457,6 +1462,7 @@ 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, 31776089133569350025876E /* SearchWebView.m in Sources */, DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */, + 89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBStashContentController.m b/PBStashContentController.m index 8432872..e6a3fe3 100644 --- a/PBStashContentController.m +++ b/PBStashContentController.m @@ -7,6 +7,7 @@ // #import "PBStashContentController.h" +#import "PBGitCommit.h" #import "PBGitDefaults.h" #import "PBGitStash.h" diff --git a/PBWebCommitController.h b/PBWebCommitController.h index 0cd4af4..e392cb5 100644 --- a/PBWebCommitController.h +++ b/PBWebCommitController.h @@ -13,6 +13,7 @@ @class NSString; @class PBGitCommit; +// Displays the diff from a commit in the repository. @interface PBWebCommitController : PBWebController { IBOutlet id contextMenuDelegate; @@ -22,10 +23,15 @@ - (void) changeContentTo: (PBGitCommit *) content; - (void) sendKey: (NSString*) key; -- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges; +- (NSString *) parseHeader:(NSString *)txt withRefs:(NSString *)badges; - (NSMutableDictionary *)parseStats:(NSString *)txt; - (NSString *) arbitraryHashForString:(NSString*)concat; - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; +- (void) didLoad; +- (NSString*) refsForCurrentCommit; +- (PBGitRef*) refFromString:(NSString*)refString; +- (NSArray*) menuItemsForPath:(NSString*)path; + @property (readonly) NSString* diff; @end diff --git a/PBWebCommitController.m b/PBWebCommitController.m index cb955db..9d2b3a1 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -200,7 +200,7 @@ { } -// TODO: need to be refactoring +// TODO: this is duplicated in PBWebDiffController - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2 { NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil]; @@ -222,9 +222,19 @@ [a setString:source forType: NSStringPboardType]; } -- (NSArray *) webView:(WebView *)sender +- (PBGitRef*) refFromString:(NSString*)refString +{ + return nil; +} + +- (NSArray*) menuItemsForPath:(NSString*)path +{ + return nil; +} + +- (NSArray *) webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element - defaultMenuItems:(NSArray *)defaultMenuItems + defaultMenuItems:(NSArray *)defaultMenuItems { DOMNode *node = [element valueForKey:@"WebElementDOMNode"]; @@ -232,16 +242,14 @@ contextMenuItemsForElement:(NSDictionary *)element // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref. if ([[node className] hasPrefix:@"refs "]) { NSString *selectedRefString = [[[node childNodes] item:0] textContent]; - for (PBGitRef *ref in historyController.webCommit.refs) - { - if ([[ref shortName] isEqualToString:selectedRefString]) - return [contextMenuDelegate menuItemsForRef:ref]; - } + PBGitRef *ref = [self refFromString:selectedRefString]; + if (ref != nil) + return [contextMenuDelegate menuItemsForRef:ref]; DLog(@"Could not find selected ref!"); return defaultMenuItems; } if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) - return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]]; + return [self menuItemsForPath:[[[node attributes] getNamedItem:@"representedFile"] value]]; else if ([[node class] isEqual:[DOMHTMLImageElement class]]) { // Copy Image is the only menu item that makes sense here since we don't need // to download the image or open it in a new window (besides with the @@ -273,11 +281,6 @@ contextMenuItemsForElement:(NSDictionary *)element return [repository valueForKeyPath:[@"config." stringByAppendingString:config]]; } -- (void)finalize -{ - [super finalize]; -} - - (void) preferencesChanged { [[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil]; diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index a692aad..1b9d26f 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -7,29 +7,14 @@ // #import -#import "PBWebController.h" - -#import "PBGitCommit.h" -#import "PBGitHistoryController.h" -#import "PBRefContextDelegate.h" +#import "PBWebCommitController.h" +@class PBGitHistoryController; @class NSString; -@interface PBWebHistoryController : PBWebController { +@interface PBWebHistoryController : PBWebCommitController { IBOutlet PBGitHistoryController* historyController; - IBOutlet id contextMenuDelegate; - - NSString* currentSha; - NSString* diff; } -- (void) changeContentTo: (PBGitCommit *) content; -- (void) sendKey: (NSString*) key; -- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges; -- (NSMutableDictionary *)parseStats:(NSString *)txt; -- (NSString *) arbitraryHashForString:(NSString*)concat; -- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; - -@property (readonly) NSString* diff; @end diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 85599f8..c08f1ed 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -8,13 +8,10 @@ #import "PBWebHistoryController.h" #import "PBGitDefaults.h" -#import "GLFileView.h" -#import +#import "PBGitHistoryController.h" @implementation PBWebHistoryController -@synthesize diff; - - (void) awakeFromNib { startFile = @"history"; @@ -33,7 +30,7 @@ - (void) didLoad { - currentSha = nil; + [super didLoad]; [self changeContentTo: historyController.webCommit]; } @@ -45,45 +42,8 @@ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } -- (void) changeContentTo: (PBGitCommit *) content +- (NSString*) refsForCurrentCommit { - if (content == nil || !finishedLoading) - return; - - currentSha = [content sha]; - - // Now we load the extended details. We used to do this in a separate thread, - // but this caused some funny behaviour because NSTask's and NSThread's don't really - // like each other. Instead, just do it async. - - NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil]; - if (![PBGitDefaults showWhitespaceDifferences]) - [taskArguments insertObject:@"-w" atIndex:1]; - - NSFileHandle *handle = [repository handleForArguments:taskArguments]; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - // Remove notification, in case we have another one running - [nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; - [nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; - [handle readToEndOfFileInBackgroundAndNotify]; -} - -- (void)commitDetailsLoaded:(NSNotification *)notification -{ - [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil]; - - NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem]; - if (!data) - return; - - NSString *details = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - if (!details) - details = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding]; - - if (!details) - return; - - NSMutableString *refs = [NSMutableString string]; NSArray *refsA = [historyController.webCommit refs]; NSString *currentRef = [[[historyController repository] headRef] simpleRef]; @@ -97,125 +57,7 @@ [refs appendString:[NSString stringWithFormat:@"%@",style,[ref shortName]]]; } - // Header - NSString *header = [self parseHeader:details withRefs:refs]; - - // File Stats - NSMutableDictionary *stats = [self parseStats:details]; - - // File list - NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; - NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; - - // Diffs list - NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; - NSString *diffs = [GLFileView parseDiff:d]; - - NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; - - html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; - html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; - - [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; - -#ifdef DEBUG_BUILD - NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; - NSString *tmpFile = @"~/tmp/test2.html"; - [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; -#endif -} - -- (NSMutableDictionary *)parseStats:(NSString *)txt -{ - NSArray *lines = [txt componentsSeparatedByString:@"\n"]; - NSMutableDictionary *stats=[NSMutableDictionary dictionary]; - int black=0; - for(NSString *line in lines){ - if([line length]==0){ - black++; - }else if(black==2){ - NSArray *file=[line componentsSeparatedByString:@"\t"]; - if([file count]==3){ - [stats setObject:file forKey:[file objectAtIndex:2]]; - } - } - } - return stats; -} - -- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges -{ - NSArray *lines = [txt componentsSeparatedByString:@"\n"]; - NSString *line; - NSString *last_mail=@""; - NSMutableString *auths=[NSMutableString string]; - NSMutableString *refs=[NSMutableString string]; - NSMutableString *subject=[NSMutableString string]; - BOOL subj=FALSE; - - int i; - for (i=0; i<[lines count]; i++) { - line=[lines objectAtIndex:i]; - if([line length]==0){ - if(!subj){ - subj=TRUE; - }else{ - i=[lines count]; - } - }else{ - if (subj) { - NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - [subject appendString:[NSString stringWithFormat:@"%@
",[GLFileView escapeHTML:trimmedLine]]]; - }else{ - NSArray *comps=[line componentsSeparatedByString:@" "]; - if([comps count]==2){ - [refs appendString:[NSString stringWithFormat:@"%@%@",[comps objectAtIndex:0],[comps objectAtIndex:1]]]; - }else if([comps count]>2){ - NSRange r_email_i = [line rangeOfString:@"<"]; - NSRange r_email_e = [line rangeOfString:@">"]; - NSRange r_name_i = [line rangeOfString:@" "]; - - NSString *rol=[line substringToIndex:r_name_i.location]; - NSString *name=[line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))]; - NSString *email=[line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))]; - - NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "]; - NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]]; - NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init]; - [theDateFormatter setDateStyle:NSDateFormatterMediumStyle]; - [theDateFormatter setTimeStyle:NSDateFormatterMediumStyle]; - NSString *dateString=[theDateFormatter stringForObjectValue:date]; - - if(![email isEqualToString:last_mail]){ - [auths appendString:[NSString stringWithFormat:@"
",rol]]; - if([self isFeatureEnabled:@"gravatar"]){ - NSString *hash=[self arbitraryHashForString:email]; - [auths appendString:[NSString stringWithFormat:@"",hash]]; - } - [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; - [auths appendString:[NSString stringWithFormat:@"

%@

",dateString]]; - } - last_mail=email; - } - } - } - } - - return [NSString stringWithFormat:@"",refs,subject,auths,badges]; -} - -- (NSString *) arbitraryHashForString:(NSString*)concat { - const char *concat_str = [concat UTF8String]; - unsigned char result[CC_MD5_DIGEST_LENGTH]; - CC_MD5(concat_str, strlen(concat_str), result); - - NSMutableString *hash = [NSMutableString string]; - - int i; - for (i = 0; i < 16; i++) - [hash appendFormat:@"%02x", result[i]]; - - return hash; + return refs; } - (void)selectCommit:(NSString *)sha @@ -223,87 +65,17 @@ [historyController selectCommit:sha]; } -// TODO: need to be refactoring -- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2 +- (PBGitRef*) refFromString:(NSString*)refString { - NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil]; - [historyController.repository handleInWorkDirForArguments:args]; + for (PBGitRef *ref in historyController.webCommit.refs) + if ([[ref shortName] isEqualToString:refString]) + return ref; + return nil; } - -- (void) sendKey: (NSString*) key +- (NSArray*) menuItemsForPath:(NSString*)path { - id script = [view windowScriptObject]; - [script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]]; -} - -- (void) copySource -{ - NSString *source = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] outerHTML]; - NSPasteboard *a =[NSPasteboard generalPasteboard]; - [a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; - [a setString:source forType: NSStringPboardType]; -} - -- (NSArray *) webView:(WebView *)sender -contextMenuItemsForElement:(NSDictionary *)element - defaultMenuItems:(NSArray *)defaultMenuItems -{ - DOMNode *node = [element valueForKey:@"WebElementDOMNode"]; - - while (node) { - // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref. - if ([[node className] hasPrefix:@"refs "]) { - NSString *selectedRefString = [[[node childNodes] item:0] textContent]; - for (PBGitRef *ref in historyController.webCommit.refs) - { - if ([[ref shortName] isEqualToString:selectedRefString]) - return [contextMenuDelegate menuItemsForRef:ref]; - } - DLog(@"Could not find selected ref!"); - return defaultMenuItems; - } - if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) - return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]]; - else if ([[node class] isEqual:[DOMHTMLImageElement class]]) { - // Copy Image is the only menu item that makes sense here since we don't need - // to download the image or open it in a new window (besides with the - // current implementation these two entries can crash GitX anyway) - for (NSMenuItem *item in defaultMenuItems) - if ([item tag] == WebMenuItemTagCopyImageToClipboard) - return [NSArray arrayWithObject:item]; - return nil; - } - - node = [node parentNode]; - } - - return defaultMenuItems; -} - - -// Open external links in the default browser -- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation - request:(NSURLRequest *)request - newFrameName:(NSString *)frameName - decisionListener:(id < WebPolicyDecisionListener >)listener -{ - [[NSWorkspace sharedWorkspace] openURL:[request URL]]; -} - -- getConfig:(NSString *)config -{ - return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]]; -} - -- (void)finalize -{ - [super finalize]; -} - -- (void) preferencesChanged -{ - [[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil]; + return [historyController menuItemsForPaths:[NSArray arrayWithObject:path]]; } @end From 10274aef55f9e3071959cf0bb4e84fabcde57a8c Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sun, 12 Jun 2011 15:23:30 -0600 Subject: [PATCH 51/63] PBViewController.superController accessor --- PBViewController.h | 1 + PBViewController.m | 1 + 2 files changed, 2 insertions(+) diff --git a/PBViewController.h b/PBViewController.h index ec5dbd4..ad6e3d5 100644 --- a/PBViewController.h +++ b/PBViewController.h @@ -20,6 +20,7 @@ } @property (readonly) __weak PBGitRepository *repository; +@property (readonly) __weak PBGitWindowController *superController; @property(copy) NSString *status; @property(assign) BOOL isBusy; diff --git a/PBViewController.m b/PBViewController.m index a0de1da..c926c19 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -12,6 +12,7 @@ @implementation PBViewController @synthesize repository; +@synthesize superController; @synthesize status; @synthesize isBusy; From 60503ba19f29992fdec759840c7a69f4d1ca0225 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sun, 12 Jun 2011 15:24:01 -0600 Subject: [PATCH 52/63] fix file name comments --- PBGitHistoryController.h | 2 +- PBGitHistoryController.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 228e2a2..36f0cfd 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -1,5 +1,5 @@ // -// PBGitHistoryView.h +// PBGitHistoryController.h // GitX // // Created by Pieter de Bie on 19-09-08. diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 64630e1..d86e16d 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -1,5 +1,5 @@ // -// PBGitHistoryView.m +// PBGitHistoryController.m // GitX // // Created by Pieter de Bie on 19-09-08. From 8053f57fbc8275aeb4e193b82bb43d863f70c6f1 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Sun, 12 Jun 2011 21:46:30 -0600 Subject: [PATCH 53/63] add PBWebStashController --- GitX.xcodeproj/project.pbxproj | 19 ++++++++++++++++--- PBGitSidebarController.h | 2 +- PBGitWindowController.h | 1 + PBGitWindowController.m | 7 +++++++ PBWebCommitController.h | 5 +++++ PBWebHistoryController.h | 2 -- PBWebStashController.h | 16 ++++++++++++++++ PBWebStashController.m | 23 +++++++++++++++++++++++ 8 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 PBWebStashController.h create mode 100644 PBWebStashController.m diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 6d96bab..132fb0d 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -81,6 +81,7 @@ 770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; }; 77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; }; 89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89087CA513A3E46B00911503 /* PBWebCommitController.m */; }; + 8998B1C613A55B3500121729 /* PBWebStashController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8998B1C513A55B3500121729 /* PBWebStashController.m */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; @@ -338,6 +339,8 @@ 77C8280C06725ACE000B614F /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = ""; }; 89087CA413A3E46500911503 /* PBWebCommitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebCommitController.h; sourceTree = ""; }; 89087CA513A3E46B00911503 /* PBWebCommitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebCommitController.m; sourceTree = ""; }; + 8998B1AC13A55AC100121729 /* PBWebStashController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebStashController.h; sourceTree = ""; }; + 8998B1C513A55B3500121729 /* PBWebStashController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebStashController.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* GitX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitX.app; sourceTree = BUILT_PRODUCTS_DIR; }; 911111E10E58BD5A00BF76B4 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/RepositoryWindow.xib; sourceTree = ""; }; @@ -849,6 +852,17 @@ name = Models; sourceTree = ""; }; + 8998B1AB13A55A9B00121729 /* Stash */ = { + isa = PBXGroup; + children = ( + DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */, + DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */, + 8998B1AC13A55AC100121729 /* PBWebStashController.h */, + 8998B1C513A55B3500121729 /* PBWebStashController.m */, + ); + name = Stash; + sourceTree = ""; + }; 913D5E420E5563FD00CECEA2 /* cli */ = { isa = PBXGroup; children = ( @@ -944,12 +958,11 @@ F5EF8C880E9D498F0050906B /* History */, F5E927F90E883EF600056E75 /* Commit */, D82F435F111B9C6D00A25A39 /* Sheets */, + 8998B1AB13A55A9B00121729 /* Stash */, 77C8280B06725ACE000B614F /* ApplicationController.h */, 77C8280C06725ACE000B614F /* ApplicationController.m */, 93CB42C00EAB7B2200530609 /* PBGitDefaults.h */, 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */, - DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */, - DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */, F57CC43F0E05E496000472E2 /* PBGitWindowController.h */, F57CC4400E05E496000472E2 /* PBGitWindowController.m */, 911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */, @@ -1209,7 +1222,6 @@ isa = PBXProject; buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -1463,6 +1475,7 @@ 31776089133569350025876E /* SearchWebView.m in Sources */, DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */, 89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */, + 8998B1C613A55B3500121729 /* PBWebStashController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index a2eb106..40e89ed 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -34,7 +34,7 @@ PBGitHistoryController *historyViewController; PBGitCommitController *commitViewController; - PBStashContentController *stashViewController; + PBStashContentController *stashViewController; } - (void) selectStage; diff --git a/PBGitWindowController.h b/PBGitWindowController.h index a3bb3cb..b00482d 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -56,6 +56,7 @@ - (IBAction) cloneTo:(id)sender; - (IBAction) refresh:(id)sender; +- (void)selectCommitForSha:(NSString*)sha; - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode; @end diff --git a/PBGitWindowController.m b/PBGitWindowController.m index e156c85..89eba03 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -234,6 +234,13 @@ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } +- (void) selectCommitForSha:(NSString *)sha +{ + if (contentController != sidebarController.historyViewController) + [sidebarController selectCurrentBranch]; + [sidebarController.historyViewController selectCommit:sha]; +} + - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode { [sidebarController setHistorySearch:searchString mode:mode]; diff --git a/PBWebCommitController.h b/PBWebCommitController.h index e392cb5..945dbbb 100644 --- a/PBWebCommitController.h +++ b/PBWebCommitController.h @@ -29,8 +29,13 @@ - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; - (void) didLoad; +// Called when a commit or parent link is clicked. +- (void)selectCommit:(NSString *)sha; +// HTML listing refs (branch name, etc) for the displayed commit. - (NSString*) refsForCurrentCommit; +// Look up a PBGitRef based on its SHA. - (PBGitRef*) refFromString:(NSString*)refString; +// Context menu items to be displayed for a file. - (NSArray*) menuItemsForPath:(NSString*)path; @property (readonly) NSString* diff; diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index 1b9d26f..5a99ca0 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -11,8 +11,6 @@ @class PBGitHistoryController; -@class NSString; - @interface PBWebHistoryController : PBWebCommitController { IBOutlet PBGitHistoryController* historyController; } diff --git a/PBWebStashController.h b/PBWebStashController.h new file mode 100644 index 0000000..7abcb93 --- /dev/null +++ b/PBWebStashController.h @@ -0,0 +1,16 @@ +// +// PBWebStashController.h +// +// Created by David Catmull on 12-06-11. +// + +#import +#import "PBWebCommitController.h" + +@class PBStashContentController; + +@interface PBWebStashController : PBWebCommitController { + IBOutlet PBStashContentController *stashController; +} + +@end diff --git a/PBWebStashController.m b/PBWebStashController.m new file mode 100644 index 0000000..ea347f0 --- /dev/null +++ b/PBWebStashController.m @@ -0,0 +1,23 @@ +// +// PBWebStashController.m +// +// Created by David Catmull on 12-06-11. +// + +#import "PBWebStashController.h" +#import "PBStashContentController.h" + +@implementation PBWebStashController + +- (void)selectCommit:(NSString *)sha +{ + [[stashController superController] selectCommitForSha:sha]; +} + +- (NSArray*) menuItemsForPath:(NSString*)path +{ + // return [[stashController superController] menuItemsForPaths:[NSArray arrayWithObject:path]]; + return nil; +} + +@end From 0ec89f165c7bfc68bd053e8bf7d5bd665b395efa Mon Sep 17 00:00:00 2001 From: David Catmull Date: Mon, 13 Jun 2011 17:51:16 -0600 Subject: [PATCH 54/63] plug in PBWebStashController --- PBStashContentController.h | 2 +- PBStashContentView.xib | 226 +++++++------------------------------ PBWebDiffController.h | 1 + 3 files changed, 42 insertions(+), 187 deletions(-) diff --git a/PBStashContentController.h b/PBStashContentController.h index 3ec6061..5ce1510 100644 --- a/PBStashContentController.h +++ b/PBStashContentController.h @@ -15,7 +15,7 @@ // Controls the view displaying a stash diff @interface PBStashContentController : PBViewController { IBOutlet id webView; - IBOutlet PBWebHistoryController *webController; + IBOutlet PBWebStashController *webController; } - (void) showStash:(PBGitStash*)stash; diff --git a/PBStashContentView.xib b/PBStashContentView.xib index 5dfb786..5230212 100644 --- a/PBStashContentView.xib +++ b/PBStashContentView.xib @@ -109,7 +109,7 @@ NSView
- PBWebHistoryController + PBWebStashController
@@ -171,6 +171,14 @@ 10 + + + stashController + + + + 11 + @@ -268,7 +276,7 @@ - 10 + 11 @@ -280,158 +288,6 @@ NSApplication+GitXScripting.h - - PBGitHistoryController - PBViewController - - YES - - YES - cherryPick: - createBranch: - createTag: - merge: - openFilesAction: - openSelectedFile: - rebase: - refresh: - selectNext: - selectPrevious: - setBranchFilter: - setDetailedView: - setTreeView: - showAddRemoteSheet: - showCommitsFromTree: - showInFinderAction: - toggleQLPreviewPanel: - updateSearch: - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - cherryPick: - createBranch: - createTag: - merge: - openFilesAction: - openSelectedFile: - rebase: - refresh: - selectNext: - selectPrevious: - setBranchFilter: - setDetailedView: - setTreeView: - showAddRemoteSheet: - showCommitsFromTree: - showInFinderAction: - toggleQLPreviewPanel: - updateSearch: - - - YES - - cherryPick: - id - - - createBranch: - id - - - createTag: - id - - - merge: - id - - - openFilesAction: - id - - - openSelectedFile: - id - - - rebase: - id - - - refresh: - id - - - selectNext: - id - - - selectPrevious: - id - - - setBranchFilter: - id - - - setDetailedView: - id - - - setTreeView: - id - - - showAddRemoteSheet: - id - - - showCommitsFromTree: - id - - - showInFinderAction: - id - - - toggleQLPreviewPanel: - id - - - updateSearch: - id - - - - - IBProjectSource - PBGitHistoryController.h - - PBGitRepository NSDocument @@ -452,7 +308,7 @@ YES - PBWebHistoryController + PBWebStashController id @@ -467,7 +323,7 @@ YES webController - PBWebHistoryController + PBWebStashController webView @@ -499,6 +355,25 @@ PBViewController.h + + PBWebCommitController + PBWebController + + contextMenuDelegate + id + + + contextMenuDelegate + + contextMenuDelegate + id + + + + IBProjectSource + PBWebCommitController.h + + PBWebController NSObject @@ -540,43 +415,22 @@ - PBWebHistoryController - PBWebController + PBWebStashController + PBWebCommitController - YES - - YES - contextMenuDelegate - historyController - - - YES - id - PBGitHistoryController - + stashController + PBStashContentController - YES - - YES - contextMenuDelegate - historyController - - - YES - - contextMenuDelegate - id - - - historyController - PBGitHistoryController - + stashController + + stashController + PBStashContentController IBProjectSource - PBWebHistoryController.h + PBWebStashController.h diff --git a/PBWebDiffController.h b/PBWebDiffController.h index bda6014..67738d3 100644 --- a/PBWebDiffController.h +++ b/PBWebDiffController.h @@ -10,6 +10,7 @@ #import "PBWebController.h" #import "PBDiffWindowController.h" +// Instantiated in PBDiffWindow.xib, used by PBDiffWindowController @interface PBWebDiffController : PBWebController { IBOutlet PBDiffWindowController *diffController; } From 93212a6efd45741487229c7a721db1c4cc9c76f8 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Mon, 13 Jun 2011 17:52:11 -0600 Subject: [PATCH 55/63] WIP refactor parsing --- PBWebCommitController.h | 3 - PBWebCommitController.m | 130 +++++++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 43 deletions(-) diff --git a/PBWebCommitController.h b/PBWebCommitController.h index 945dbbb..20893b2 100644 --- a/PBWebCommitController.h +++ b/PBWebCommitController.h @@ -23,9 +23,6 @@ - (void) changeContentTo: (PBGitCommit *) content; - (void) sendKey: (NSString*) key; -- (NSString *) parseHeader:(NSString *)txt withRefs:(NSString *)badges; -- (NSMutableDictionary *)parseStats:(NSString *)txt; -- (NSString *) arbitraryHashForString:(NSString*)concat; - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; - (void) didLoad; diff --git a/PBWebCommitController.m b/PBWebCommitController.m index 9d2b3a1..54d04b0 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -10,6 +10,16 @@ #import "GLFileView.h" #import +@interface PBWebCommitController (Private) + +- (NSArray *)parseHeader:(NSString *)text; +- (NSString *)htmlForHeader:(NSArray *)header withRefs:(NSString *)badges; +- (NSMutableDictionary *)parseStats:(NSString *)txt; +- (NSString *) arbitraryHashForString:(NSString*)concat; + +@end + + @implementation PBWebCommitController @synthesize diff; @@ -71,7 +81,8 @@ return; // Header - NSString *header = [self parseHeader:details withRefs:[self refsForCurrentCommit]]; + NSArray *headerItems = [self parseHeader:details]; + NSString *header = [self htmlForHeader:details withRefs:[self refsForCurrentCommit]]; // File Stats NSMutableDictionary *stats = [self parseStats:details]; @@ -121,60 +132,99 @@ return stats; } -- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges +// -parseHeader: returns an array of dictionaries with these keys +const NSString *kHeaderKeyName = @"name"; +const NSString *kHeaderKeyContent = @"content"; + +// Keys for the author/committer dictionary +const NSString *kAuthorKeyName = @"name"; +const NSString *kAuthorKeyEmail = @"email"; +const NSString *kAuthorKeyDate = @"date"; + +- (NSArray *)parseHeader:(NSString *)text { - NSArray *lines = [txt componentsSeparatedByString:@"\n"]; - NSString *line; - NSString *last_mail=@""; - NSMutableString *auths=[NSMutableString string]; - NSMutableString *refs=[NSMutableString string]; - NSMutableString *subject=[NSMutableString string]; - BOOL subj=FALSE; + NSMutableArray *result = [NSMutableArray array]; + NSArray *lines = [text componentsSeparatedByString:@"\n"]; + BOOL parsingSubject = NO; - int i; - for (i=0; i<[lines count]; i++) { - line=[lines objectAtIndex:i]; - if([line length]==0){ - if(!subj){ - subj=TRUE; - }else{ - i=[lines count]; - } - }else{ - if (subj) { - NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - [subject appendString:[NSString stringWithFormat:@"%@
",[GLFileView escapeHTML:trimmedLine]]]; - }else{ - NSArray *comps=[line componentsSeparatedByString:@" "]; - if([comps count]==2){ - [refs appendString:[NSString stringWithFormat:@"%@%@",[comps objectAtIndex:0],[comps objectAtIndex:1]]]; - }else if([comps count]>2){ + for (NSString *line in lines) { + if ([line length] == 0) { + if (!parsingSubject) + parsingSubject = TRUE; + else + break; + } else { + if (parsingSubject) { + NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + [result addObject:[NSDictionary dictionaryWithObjectsAndKeys: + @"subject", kHeaderKeyName, trimmedLine, kHeaderKeyContent, nil]]; + } else { + NSArray *comps = [line componentsSeparatedByString:@" "]; + if ([comps count] == 2) { + [result addObject:[NSDictionary dictionaryWithObjectsAndKeys: + [comps objectAtIndex:0], kHeaderKeyName, + [comps objectAtIndex:1], kHeaderKeyContent, nil]]; + } else if ([comps count] > 2) { NSRange r_email_i = [line rangeOfString:@"<"]; NSRange r_email_e = [line rangeOfString:@">"]; NSRange r_name_i = [line rangeOfString:@" "]; - NSString *rol=[line substringToIndex:r_name_i.location]; - NSString *name=[line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))]; - NSString *email=[line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))]; + NSString *name = [line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))]; + NSString *email = [line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))]; NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "]; NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]]; + + [result addObject:[NSDictionary dictionaryWithObjectsAndKeys: + [comps objectAtIndex:0], kHeaderKeyName, + [NSDictionary dictionaryWithObjectsAndKeys: + name, kAuthorKeyName, + email, kAuthorKeyEmail, + date, kAuthorKeyDate, + nil], + nil]]; + } + } + } + } + + return result; +} + +- (NSString *)htmlForHeader:(NSArray *)header withRefs:(NSString *)badges +{ + NSString *last_mail = @""; + NSMutableString *auths=[NSMutableString string]; + NSMutableString *refs=[NSMutableString string]; + NSMutableString *subject=[NSMutableString string]; + + for (NSDictionary *item in header) { + if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"subject"]) { + [subject appendString:[NSString stringWithFormat:@"%@
",[GLFileView escapeHTML:[item objectForKey:kHeaderKeyContent]]]]; + }else{ + if([[item objectForKey:kHeaderKeyContent] isKindOfClass:[NSString class]]){ + [refs appendString:[NSString stringWithFormat:@"%@%@",[item objectForKey:kHeaderKeyName],[item objectForKey:kHeaderKeyContent]]]; + }else{ // NSDictionary: author or committer + NSDictionary *content = [item objectForKey:kHeaderKeyContent]; + NSString *email = [content objectForKey:kAuthorKeyEmail]; + + if(![email isEqualToString:last_mail]){ + NSString *name = [content objectForKey:kAuthorKeyName]; + NSDate *date = [content objectForKey:kAuthorKeyDate]; NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init]; [theDateFormatter setDateStyle:NSDateFormatterMediumStyle]; [theDateFormatter setTimeStyle:NSDateFormatterMediumStyle]; NSString *dateString=[theDateFormatter stringForObjectValue:date]; - - if(![email isEqualToString:last_mail]){ - [auths appendString:[NSString stringWithFormat:@"
",rol]]; - if([self isFeatureEnabled:@"gravatar"]){ - NSString *hash=[self arbitraryHashForString:email]; - [auths appendString:[NSString stringWithFormat:@"",hash]]; - } - [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; - [auths appendString:[NSString stringWithFormat:@"

%@

",dateString]]; + + [auths appendString:[NSString stringWithFormat:@"
",rol]]; + if([self isFeatureEnabled:@"gravatar"]){ + NSString *hash=[self arbitraryHashForString:email]; + [auths appendString:[NSString stringWithFormat:@"",hash]]; } - last_mail=email; + [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; + [auths appendString:[NSString stringWithFormat:@"

%@

",dateString]]; } + last_mail=email; } } } From fc3ef16e3a5c3b162fedf03b3234c47bd96d2b4a Mon Sep 17 00:00:00 2001 From: David Catmull Date: Tue, 14 Jun 2011 17:20:35 -0600 Subject: [PATCH 56/63] finish parser refactor --- PBWebCommitController.m | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/PBWebCommitController.m b/PBWebCommitController.m index 54d04b0..0fc2697 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -82,7 +82,7 @@ // Header NSArray *headerItems = [self parseHeader:details]; - NSString *header = [self htmlForHeader:details withRefs:[self refsForCurrentCommit]]; + NSString *header = [self htmlForHeader:headerItems withRefs:[self refsForCurrentCommit]]; // File Stats NSMutableDictionary *stats = [self parseStats:details]; @@ -175,13 +175,14 @@ const NSString *kAuthorKeyDate = @"date"; NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "]; NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]]; + NSDictionary *content = [NSDictionary dictionaryWithObjectsAndKeys: + name, kAuthorKeyName, + email, kAuthorKeyEmail, + date, kAuthorKeyDate, + nil]; [result addObject:[NSDictionary dictionaryWithObjectsAndKeys: [comps objectAtIndex:0], kHeaderKeyName, - [NSDictionary dictionaryWithObjectsAndKeys: - name, kAuthorKeyName, - email, kAuthorKeyEmail, - date, kAuthorKeyDate, - nil], + content, kHeaderKeyContent, nil]]; } } @@ -216,12 +217,12 @@ const NSString *kAuthorKeyDate = @"date"; [theDateFormatter setTimeStyle:NSDateFormatterMediumStyle]; NSString *dateString=[theDateFormatter stringForObjectValue:date]; - [auths appendString:[NSString stringWithFormat:@"
",rol]]; + [auths appendString:[NSString stringWithFormat:@"
",[item objectForKey:kHeaderKeyName]]]; if([self isFeatureEnabled:@"gravatar"]){ NSString *hash=[self arbitraryHashForString:email]; [auths appendString:[NSString stringWithFormat:@"",hash]]; } - [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,rol]]; + [auths appendString:[NSString stringWithFormat:@"

%@ (%@)

",name,[item objectForKey:kHeaderKeyName]]]; [auths appendString:[NSString stringWithFormat:@"

%@

",dateString]]; } last_mail=email; From c02046e64788eb08151f0f615f67260e20b7c8d4 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Tue, 14 Jun 2011 17:20:56 -0600 Subject: [PATCH 57/63] JavaScript fix --- html/lib/SearchWebView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/lib/SearchWebView.js b/html/lib/SearchWebView.js index c09aa88..75321e7 100644 --- a/html/lib/SearchWebView.js +++ b/html/lib/SearchWebView.js @@ -32,7 +32,7 @@ function HighlightAllOccurencesOfStringForElement(element,keyword) { } else if (element.nodeType == 1) { // Element node if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') { for (var i=0; i"+element.childNodes[i].getAttribute('class')); HighlightAllOccurencesOfStringForElement(element.childNodes[i],keyword); } From 8676e86ea7ebf5fc99f91c7b4314f5b5fc7a8d25 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Tue, 14 Jun 2011 17:38:55 -0600 Subject: [PATCH 58/63] fix display for merge commits, which stashes happen to be git diff-tree has to be explicitly given the list of parents --- PBWebCommitController.m | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/PBWebCommitController.m b/PBWebCommitController.m index 0fc2697..8d2be14 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -19,6 +19,14 @@ @end +// -parseHeader: returns an array of dictionaries with these keys +const NSString *kHeaderKeyName = @"name"; +const NSString *kHeaderKeyContent = @"content"; + +// Keys for the author/committer dictionary +const NSString *kAuthorKeyName = @"name"; +const NSString *kAuthorKeyEmail = @"email"; +const NSString *kAuthorKeyDate = @"date"; @implementation PBWebCommitController @@ -84,15 +92,29 @@ NSArray *headerItems = [self parseHeader:details]; NSString *header = [self htmlForHeader:headerItems withRefs:[self refsForCurrentCommit]]; + // In case the commit is a merge, we need to explicity give diff-tree the + // list of parents, or else it will yield an empty result. + // If it's not a merge, this won't hurt. + NSMutableArray *parentsArray = [NSMutableArray array]; + + for (NSDictionary *item in headerItems) { + if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"parent"]) { + [parentsArray addObject:[item objectForKey:kHeaderKeyContent]]; + break; + } + } + + NSString *parents = [parentsArray componentsJoinedByString:@" "]; + // File Stats NSMutableDictionary *stats = [self parseStats:details]; // File list - NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, parents, nil]]; NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; + NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, parents, nil]]; NSString *diffs = [GLFileView parseDiff:d]; NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; @@ -132,15 +154,6 @@ return stats; } -// -parseHeader: returns an array of dictionaries with these keys -const NSString *kHeaderKeyName = @"name"; -const NSString *kHeaderKeyContent = @"content"; - -// Keys for the author/committer dictionary -const NSString *kAuthorKeyName = @"name"; -const NSString *kAuthorKeyEmail = @"email"; -const NSString *kAuthorKeyDate = @"date"; - - (NSArray *)parseHeader:(NSString *)text { NSMutableArray *result = [NSMutableArray array]; From 4a2c139fb9b63038e80626599b88d20c81445d04 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Wed, 15 Jun 2011 21:16:02 -0600 Subject: [PATCH 59/63] menus for files in stash view --- PBGitWindowController.h | 3 ++- PBGitWindowController.m | 5 +++++ PBWebStashController.m | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PBGitWindowController.h b/PBGitWindowController.h index b00482d..266422c 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -56,7 +56,8 @@ - (IBAction) cloneTo:(id)sender; - (IBAction) refresh:(id)sender; -- (void)selectCommitForSha:(NSString*)sha; +- (void)selectCommitForSha:(NSString *)sha; +- (NSArray *)menuItemsForPaths:(NSArray *)paths; - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode; @end diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 89eba03..5579af2 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -241,6 +241,11 @@ [sidebarController.historyViewController selectCommit:sha]; } +- (NSArray *) menuItemsForPaths:(NSArray *)paths +{ + return [sidebarController.historyViewController menuItemsForPaths:paths]; +} + - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode { [sidebarController setHistorySearch:searchString mode:mode]; diff --git a/PBWebStashController.m b/PBWebStashController.m index ea347f0..0ad6a94 100644 --- a/PBWebStashController.m +++ b/PBWebStashController.m @@ -16,8 +16,7 @@ - (NSArray*) menuItemsForPath:(NSString*)path { - // return [[stashController superController] menuItemsForPaths:[NSArray arrayWithObject:path]]; - return nil; + return [[stashController superController] menuItemsForPaths:[NSArray arrayWithObject:path]]; } @end From 0659d793a215a04bcfc5458521a06b51f6d8d380 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Wed, 15 Jun 2011 21:42:29 -0600 Subject: [PATCH 60/63] split pane --- PBStashContentController.h | 3 +- PBStashContentController.m | 17 ++- PBStashContentView.xib | 283 ++++++++++++++++++++++++++++--------- 3 files changed, 232 insertions(+), 71 deletions(-) diff --git a/PBStashContentController.h b/PBStashContentController.h index 5ce1510..adf50ec 100644 --- a/PBStashContentController.h +++ b/PBStashContentController.h @@ -15,7 +15,8 @@ // Controls the view displaying a stash diff @interface PBStashContentController : PBViewController { IBOutlet id webView; - IBOutlet PBWebStashController *webController; + IBOutlet PBWebStashController *unstagedController; + IBOutlet PBWebStashController *stagedController; } - (void) showStash:(PBGitStash*)stash; diff --git a/PBStashContentController.m b/PBStashContentController.m index e6a3fe3..da0b2f4 100644 --- a/PBStashContentController.m +++ b/PBStashContentController.m @@ -11,11 +11,14 @@ #import "PBGitDefaults.h" #import "PBGitStash.h" +const CGFloat kMinPaneSize = 32.0; + @implementation PBStashContentController - (void) awakeFromNib { - [webController setRepository:repository]; + [unstagedController setRepository:repository]; + [stagedController setRepository:repository]; } - (void) showStash:(PBGitStash*)stash @@ -24,7 +27,17 @@ NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]]; PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha]; - [webController changeContentTo:commit]; + [unstagedController changeContentTo:commit]; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex +{ + return kMinPaneSize; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex +{ + return [splitView frame].size.height - kMinPaneSize; } @end diff --git a/PBStashContentView.xib b/PBStashContentView.xib index 5230212..223b589 100644 --- a/PBStashContentView.xib +++ b/PBStashContentView.xib @@ -3,7 +3,7 @@ 1060 10J869 - 851 + 788 1038.35 461.00 @@ -15,18 +15,18 @@ YES - 851 - 851 + 788 + 788
YES - + YES - com.apple.WebKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin YES @@ -53,64 +53,110 @@ 274 YES - + 274 - + YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {480, 272} + + + + + + + + YES + + YES + WebKitDefaultFixedFontSize + WebKitDefaultFontSize + WebKitMinimumFontSize + + + YES + + + + + + + YES + YES + + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {{0, 282}, {480, 272}} + + + + + + YES + YES - {480, 272} + {480, 554} - - - - - - - YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - - - YES - - - - - - - YES - YES + 3 - {480, 272} + {480, 554} NSView PBWebStashController + + PBWebStashController + @@ -147,14 +193,6 @@ 7 - - - webController - - - - 8 - view @@ -179,6 +217,70 @@ 11 + + + unstagedController + + + + 12 + + + + stashController + + + + 15 + + + + stagedController + + + + 16 + + + + view + + + + 22 + + + + frameLoadDelegate + + + + 23 + + + + policyDelegate + + + + 24 + + + + UIDelegate + + + + 25 + + + + delegate + + + + 26 + @@ -212,20 +314,42 @@ YES - + Stash - - 2 - - - 3 + Unstaged Controller + + + 13 + + + Staged Controller + + + 21 + + + YES + + + + + + + 2 + + + + + 17 + + @@ -240,6 +364,9 @@ 1.IBPluginDependency 1.WindowOrigin 1.editorWindowContentRectSynchronizationRect + 13.IBPluginDependency + 17.IBPluginDependency + 17.IBViewBoundsToFrameTransform 2.IBPluginDependency 2.IBViewBoundsToFrameTransform 3.IBPluginDependency @@ -249,10 +376,15 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{14, 862}, {480, 272}} + {{786, 804}, {480, 554}} com.apple.InterfaceBuilder.CocoaPlugin {628, 654} {{357, 416}, {480, 272}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + AUJwAABCFAAAA + com.apple.WebKitIBPlugin AUJwAABCFAAAA @@ -276,7 +408,7 @@
- 11 + 26 @@ -303,12 +435,14 @@ YES YES - webController + stagedController + unstagedController webView YES PBWebStashController + PBWebStashController id @@ -316,13 +450,18 @@ YES YES - webController + stagedController + unstagedController webView YES - webController + stagedController + PBWebStashController + + + unstagedController PBWebStashController @@ -968,6 +1107,14 @@ AppKit.framework/Headers/NSSearchField.h + + NSSplitView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSSplitView.h + + NSTextField NSControl From 26ada648cc9e484638e4c10182a3f75e29f04917 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Thu, 16 Jun 2011 17:54:42 -0600 Subject: [PATCH 61/63] show index in lower pane --- PBStashContentController.m | 7 +++++-- PBWebCommitController.h | 2 ++ PBWebCommitController.m | 7 ++++++- PBWebStashController.m | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/PBStashContentController.m b/PBStashContentController.m index da0b2f4..b7cc628 100644 --- a/PBStashContentController.m +++ b/PBStashContentController.m @@ -24,10 +24,13 @@ const CGFloat kMinPaneSize = 32.0; - (void) showStash:(PBGitStash*)stash { NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]]; - NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]]; - PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha]; + NSString *stashSHA = [repository shaForRef:[PBGitRef refFromString:stashRef]]; + PBGitCommit *commit = [repository commitForSHA:stashSHA]; + NSString *indexSHA = [commit.parents objectAtIndex:1]; + PBGitCommit *indexCommit = [repository commitForSHA:indexSHA]; [unstagedController changeContentTo:commit]; + [stagedController changeContentTo:indexCommit]; } - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex diff --git a/PBWebCommitController.h b/PBWebCommitController.h index 20893b2..2d53023 100644 --- a/PBWebCommitController.h +++ b/PBWebCommitController.h @@ -32,6 +32,8 @@ - (NSString*) refsForCurrentCommit; // Look up a PBGitRef based on its SHA. - (PBGitRef*) refFromString:(NSString*)refString; +// Choose which parents should be used for the diff +- (NSArray*) chooseDiffParents:(NSArray*)parents; // Context menu items to be displayed for a file. - (NSArray*) menuItemsForPath:(NSString*)path; diff --git a/PBWebCommitController.m b/PBWebCommitController.m index 8d2be14..f5002bd 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -104,7 +104,7 @@ const NSString *kAuthorKeyDate = @"date"; } } - NSString *parents = [parentsArray componentsJoinedByString:@" "]; + NSString *parents = [[self chooseDiffParents:parentsArray] componentsJoinedByString:@" "]; // File Stats NSMutableDictionary *stats = [self parseStats:details]; @@ -136,6 +136,11 @@ const NSString *kAuthorKeyDate = @"date"; return @""; } +- (NSArray*) chooseDiffParents:(NSArray *)parents +{ + return parents; +} + - (NSMutableDictionary *)parseStats:(NSString *)txt { NSArray *lines = [txt componentsSeparatedByString:@"\n"]; diff --git a/PBWebStashController.m b/PBWebStashController.m index 0ad6a94..ea39534 100644 --- a/PBWebStashController.m +++ b/PBWebStashController.m @@ -19,4 +19,9 @@ return [[stashController superController] menuItemsForPaths:[NSArray arrayWithObject:path]]; } +- (NSArray*) chooseDiffParents:(NSArray *)parents +{ + return [NSArray arrayWithObject:[parents objectAtIndex:0]]; +} + @end From 73b548cd6731bd73d2314b90f386c205aef8a384 Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 17 Jun 2011 12:12:48 -0600 Subject: [PATCH 62/63] fix inverted diff --- PBWebCommitController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBWebCommitController.m b/PBWebCommitController.m index f5002bd..e442ee6 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -114,7 +114,7 @@ const NSString *kAuthorKeyDate = @"date"; NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, parents, nil]]; + NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", parents, currentSha, nil]]; NSString *diffs = [GLFileView parseDiff:d]; NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; From ba51ae810bd5db60addc873c3ad6fbe97e2834ac Mon Sep 17 00:00:00 2001 From: David Catmull Date: Fri, 17 Jun 2011 13:52:33 -0600 Subject: [PATCH 63/63] fix parent handling --- PBWebCommitController.m | 23 +++++++++++++---------- PBWebStashController.m | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/PBWebCommitController.m b/PBWebCommitController.m index e442ee6..79fb31f 100644 --- a/PBWebCommitController.m +++ b/PBWebCommitController.m @@ -95,26 +95,29 @@ const NSString *kAuthorKeyDate = @"date"; // In case the commit is a merge, we need to explicity give diff-tree the // list of parents, or else it will yield an empty result. // If it's not a merge, this won't hurt. - NSMutableArray *parentsArray = [NSMutableArray array]; + NSMutableArray *allParents = [NSMutableArray array]; - for (NSDictionary *item in headerItems) { - if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"parent"]) { - [parentsArray addObject:[item objectForKey:kHeaderKeyContent]]; - break; - } - } + for (NSDictionary *item in headerItems) + if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"parent"]) + [allParents addObject:[item objectForKey:kHeaderKeyContent]]; - NSString *parents = [[self chooseDiffParents:parentsArray] componentsJoinedByString:@" "]; + NSArray *parents = [self chooseDiffParents:allParents]; // File Stats NSMutableDictionary *stats = [self parseStats:details]; // File list - NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, parents, nil]]; + NSMutableArray *args = [NSMutableArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", nil]; + [args addObjectsFromArray:parents]; + [args addObject:currentSha]; + NSString *dt = [repository outputInWorkdirForArguments:args]; NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", parents, currentSha, nil]]; + args = [NSMutableArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", nil]; + [args addObjectsFromArray:parents]; + [args addObject:currentSha]; + NSString *d = [repository outputInWorkdirForArguments:args]; NSString *diffs = [GLFileView parseDiff:d]; NSString *html = [NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; diff --git a/PBWebStashController.m b/PBWebStashController.m index ea39534..82bef0f 100644 --- a/PBWebStashController.m +++ b/PBWebStashController.m @@ -21,7 +21,7 @@ - (NSArray*) chooseDiffParents:(NSArray *)parents { - return [NSArray arrayWithObject:[parents objectAtIndex:0]]; + return [NSArray arrayWithObject:[parents lastObject]]; } @end