diff --git a/.gitignore b/.gitignore index 6492eef..39b9099 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store build build/revision ._* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 6794840..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "libgit2"] - path = libgit2 - url = git://repo.or.cz/libgit2.git \ No newline at end of file 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/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/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/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 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/GLFileView.m b/GLFileView.m index 6d4e7e5..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 @@ -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])]; diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index eea9e05..132fb0d 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -80,6 +80,8 @@ 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 */; }; + 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 */; }; @@ -129,7 +131,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 */; }; @@ -139,6 +140,8 @@ 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 /* 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 */; }; @@ -178,7 +181,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 +216,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 */; @@ -342,6 +337,10 @@ 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 = ""; }; + 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 = ""; }; @@ -417,8 +416,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 = ""; }; @@ -436,6 +433,9 @@ 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 /* 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 = ""; }; @@ -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 = ""; }; @@ -560,7 +560,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; @@ -777,6 +776,7 @@ F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */, F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */, F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */, + DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */, D85B939210E3D8B4007F3C28 /* PBCreateBranchSheet.xib */, D889EB3010E6BCBB00F08413 /* PBCreateTagSheet.xib */, D8C1B77110E875CF009B7F8B /* PBRemoteProgressSheet.xib */, @@ -852,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 = ( @@ -947,6 +958,7 @@ F5EF8C880E9D498F0050906B /* History */, F5E927F90E883EF600056E75 /* Commit */, D82F435F111B9C6D00A25A39 /* Sheets */, + 8998B1AB13A55A9B00121729 /* Stash */, 77C8280B06725ACE000B614F /* ApplicationController.h */, 77C8280C06725ACE000B614F /* ApplicationController.m */, 93CB42C00EAB7B2200530609 /* PBGitDefaults.h */, @@ -957,6 +969,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 */, @@ -1084,8 +1098,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 +1158,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 +1192,6 @@ 551BF175112F3F3500265053 /* PBXTargetDependency */, 913D5E5A0E5564F400CECEA2 /* PBXTargetDependency */, F5643A020F792B4900A579C2 /* PBXTargetDependency */, - D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */, ); name = GitX; productInstallPath = "$(HOME)/Applications"; @@ -1241,7 +1236,6 @@ 8D1107260486CEB800E47090 /* GitX */, 913D5E480E55644600CECEA2 /* cli tool */, F56439F70F792B2100A579C2 /* Generate PList Prefix */, - D8022B1411DFCE7F003C21F6 /* libgit2 */, 551BF110112F371800265053 /* gitx_askpasswd */, ); }; @@ -1317,6 +1311,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; }; @@ -1337,7 +1332,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; @@ -1451,7 +1446,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 */, @@ -1479,6 +1473,9 @@ 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, 31776089133569350025876E /* SearchWebView.m in Sources */, + DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */, + 89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */, + 8998B1C613A55B3500121729 /* PBWebStashController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1505,11 +1502,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 */; @@ -1604,6 +1596,7 @@ 26FC0A850875C7B200E6366F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1616,13 +1609,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; @@ -1633,6 +1627,7 @@ 26FC0A860875C7B200E6366F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1643,13 +1638,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; @@ -1695,6 +1690,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; @@ -1703,6 +1699,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, @@ -1719,6 +1716,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; @@ -1743,6 +1741,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; @@ -1763,6 +1762,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; @@ -1771,7 +1771,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, @@ -1788,6 +1789,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; @@ -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, @@ -1809,32 +1811,10 @@ }; name = Release; }; - D8022B1511DFCE7F003C21F6 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = libgit2; - SDKROOT = ""; - }; - name = Debug; - }; - D8022B1611DFCE7F003C21F6 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - 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 = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -1846,6 +1826,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; @@ -1896,15 +1877,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/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/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 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; 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/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]; } 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]; 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]; diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index d22ba6c..98827d2 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -11,7 +11,6 @@ #import "PBGitLane.h" #import "PBGitGraphLine.h" #import -#import "git/oid.h" 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 201fbcf..568858c 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. @@ -18,12 +18,12 @@ @class QLPreviewPanel; @class PBCommitList; @class GLFileView; -@class PBGitSHA; +@class NSString; @class PBHistorySearchController; // Controls the split history view from PBGitHistoryView.xib -@interface PBGitHistoryController : PBViewController /**/{ +@interface PBGitHistoryController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate){ IBOutlet PBRefController *refController; IBOutlet NSSearchField *searchField; IBOutlet NSArrayController* commitController; @@ -34,7 +34,7 @@ IBOutlet PBCommitList* commitList; IBOutlet NSSplitView *historySplitView; IBOutlet PBWebHistoryController *webHistoryController; - QLPreviewPanel* previewPanel; + QLPreviewPanel* previewPanel; IBOutlet PBHistorySearchController *searchController; IBOutlet GLFileView *fileView; @@ -72,7 +72,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..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. @@ -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]; } @@ -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 94b59a2..2591621 100644 --- a/PBGitLane.h +++ b/PBGitLane.h @@ -6,46 +6,32 @@ // Copyright 2008 __MyCompanyName__. All rights reserved. // #import -#include "git/oid.h" 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 fe5369d..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 PBGitSHA; +@class PBGitResetController; +@class PBStashController; +@class PBSubmoduleController; @interface PBGitRepository : NSDocument { PBGitHistoryList* revisionList; @@ -55,7 +53,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { NSMutableDictionary *refs; PBGitRevSpecifier *_headRef; // Caching - PBGitSHA* _headSha; + NSString* _headSha; PBStashController *stashController; PBSubmoduleController *submoduleController; @@ -88,6 +86,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; @@ -111,13 +110,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; @@ -127,6 +126,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 41bc6f0..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" @@ -118,6 +121,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 +157,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 @@ -265,11 +277,16 @@ 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); + return; + } NSMutableArray* curRefs; if ( (curRefs = [refs objectForKey:sha]) != nil ) @@ -278,6 +295,41 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha]; } +// 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 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; @@ -290,6 +342,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) @@ -300,6 +359,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]; @@ -353,7 +413,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return _headRef; } -- (PBGitSHA *)headSHA +- (NSString *)headSHA { if (! _headSha) [self headRef]; @@ -366,12 +426,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; @@ -382,7 +442,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; if (retValue || [shaForRef isEqualToString:@""]) return nil; - return [PBGitSHA shaWithString:shaForRef]; + return shaForRef; } - (PBGitCommit *)commitForRef:(PBGitRef *)ref @@ -393,7 +453,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return [self commitForSHA:[self shaForRef:ref]]; } -- (PBGitCommit *)commitForSHA:(PBGitSHA *)sha +- (PBGitCommit *)commitForSHA:(NSString *)sha { if (!sha) return nil; @@ -410,7 +470,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; @@ -423,7 +483,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; @@ -437,12 +497,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 58992bf..4295b3c 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; @@ -147,9 +157,14 @@ using namespace std; } } - git_oid oid; - git_oid_mkstr(&oid, sha.c_str()); - PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:[PBGitSHA shaWithOID:oid]]; + NSString *oid=[NSString stringWithCString:sha.c_str() encoding:encoding]; + if([oid length]!=40) + break; + + PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:oid]; + + if (showSign) + [newCommit setSign: sign]; string author; getline(stream, author, '\1'); @@ -157,11 +172,9 @@ using namespace std; string committer; getline(stream, committer, '\1'); - string subject; - getline(stream, subject, '\1'); - string parentString; getline(stream, parentString, '\1'); + if (parentString.size() != 0) { if (((parentString.size() + 1) % 41) != 0) { @@ -171,35 +184,24 @@ 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]; } 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]; 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/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 f222911..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 "git/oid.h" - - -@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 1745133..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" - - -@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/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..40e89ed 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -12,17 +12,18 @@ @class PBSourceViewItem; @class PBGitHistoryController; @class PBGitCommitController; +@class PBStashContentController; -@interface PBGitSidebarController : PBViewController /**/{ +@interface PBGitSidebarController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate, NSMenuDelegate){ IBOutlet NSWindow *window; IBOutlet NSOutlineView *sourceView; IBOutlet NSView *sourceListControlsView; 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; @@ -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 dad7de1..14dd91d 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -23,6 +23,8 @@ #import "PBCommandMenuItem.h" #import "PBGitStash.h" #import "PBGitSubmodule.h" +#import "PBSubmoduleController.h" +#import "PBStashContentController.h" static NSString * const kObservingContextStashes = @"stashesChanged"; static NSString * const kObservingContextSubmodules = @"submodulesChanged"; @@ -42,6 +44,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; @synthesize sourceListControlsView; @synthesize historyViewController; @synthesize commitViewController; +@synthesize stashViewController; - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller { @@ -60,6 +63,9 @@ 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]; + + [stashViewController loadView]; [repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"]; [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"]; @@ -83,6 +89,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; { [historyViewController closeView]; [commitViewController closeView]; + [stashViewController closeView]; [repository removeObserver:self forKeyPath:@"currentBranch"]; [repository removeObserver:self forKeyPath:@"branches"]; @@ -318,6 +325,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]; } @@ -342,6 +355,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]; @@ -360,6 +378,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]]; @@ -379,6 +408,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/PBGitWindowController.h b/PBGitWindowController.h index 9d6ef83..22eb440 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -15,7 +15,7 @@ @class PBViewController, PBGitSidebarController, PBGitCommitController; // Controls the main repository window from RepositoryWindow.xib -@interface PBGitWindowController : NSWindowController /**/{ +@interface PBGitWindowController : NSWindowController PROTOCOL_10_6(NSWindowDelegate){ __weak PBGitRepository* repository; PBViewController *contentController; @@ -57,6 +57,8 @@ - (IBAction) cloneTo:(id)sender; - (IBAction) refresh:(id)sender; +- (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 e156c85..5579af2 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -234,6 +234,18 @@ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } +- (void) selectCommitForSha:(NSString *)sha +{ + if (contentController != sidebarController.historyViewController) + [sidebarController selectCurrentBranch]; + [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/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/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/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" diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index 2c9fd5a..2e7b91b 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 @@ -33,7 +35,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]; } @@ -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; } diff --git a/PBSourceViewItem.h b/PBSourceViewItem.h index 6d12451..ee6ada4 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; diff --git a/PBStashContentController.h b/PBStashContentController.h new file mode 100644 index 0000000..adf50ec --- /dev/null +++ b/PBStashContentController.h @@ -0,0 +1,24 @@ +// +// PBStashContentController.h +// GitX +// +// Created by David Catmull on 20-06-11. +// Copyright 2011. All rights reserved. +// + +#import "PBViewController.h" +#import "PBWebHistoryController.h" + +@class PBGitStash; +@class PBWebStashController; + +// Controls the view displaying a stash diff +@interface PBStashContentController : PBViewController { + IBOutlet id webView; + IBOutlet PBWebStashController *unstagedController; + IBOutlet PBWebStashController *stagedController; +} + +- (void) showStash:(PBGitStash*)stash; + +@end diff --git a/PBStashContentController.m b/PBStashContentController.m new file mode 100644 index 0000000..b7cc628 --- /dev/null +++ b/PBStashContentController.m @@ -0,0 +1,46 @@ +// +// PBStashContentController.h +// GitX +// +// Created by David Catmull on 20-06-11. +// Copyright 2011. All rights reserved. +// + +#import "PBStashContentController.h" +#import "PBGitCommit.h" +#import "PBGitDefaults.h" +#import "PBGitStash.h" + +const CGFloat kMinPaneSize = 32.0; + +@implementation PBStashContentController + +- (void) awakeFromNib +{ + [unstagedController setRepository:repository]; + [stagedController setRepository:repository]; +} + +- (void) showStash:(PBGitStash*)stash +{ + NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]]; + 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 +{ + 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 new file mode 100644 index 0000000..223b589 --- /dev/null +++ b/PBStashContentView.xib @@ -0,0 +1,1308 @@ + + + + 1060 + 10J869 + 788 + 1038.35 + 461.00 + + YES + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + 788 + 788 + + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + + YES + + + YES + + + + YES + + PBStashContentController + + + FirstResponder + + + NSApplication + + + + 274 + + YES + + + 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 + + + + 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, 554} + + 3 + + + {480, 554} + + NSView + + + PBWebStashController + + + PBWebStashController + + + + + YES + + + view + + + + 4 + + + + frameLoadDelegate + + + + 5 + + + + policyDelegate + + + + 6 + + + + UIDelegate + + + + 7 + + + + view + + + + 9 + + + + webView + + + + 10 + + + + stashController + + + + 11 + + + + unstagedController + + + + 12 + + + + stashController + + + + 15 + + + + stagedController + + + + 16 + + + + view + + + + 22 + + + + frameLoadDelegate + + + + 23 + + + + policyDelegate + + + + 24 + + + + UIDelegate + + + + 25 + + + + delegate + + + + 26 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + Stash + + + 3 + + + Unstaged Controller + + + 13 + + + Staged Controller + + + 21 + + + YES + + + + + + + 2 + + + + + 17 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 13.IBPluginDependency + 17.IBPluginDependency + 17.IBViewBoundsToFrameTransform + 2.IBPluginDependency + 2.IBViewBoundsToFrameTransform + 3.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{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 + + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 26 + + + + YES + + NSApplication + + IBProjectSource + NSApplication+GitXScripting.h + + + + PBGitRepository + NSDocument + + IBProjectSource + PBGitRepository.h + + + + PBStashContentController + PBViewController + + YES + + YES + stagedController + unstagedController + webView + + + YES + PBWebStashController + PBWebStashController + id + + + + YES + + YES + stagedController + unstagedController + webView + + + YES + + stagedController + PBWebStashController + + + unstagedController + PBWebStashController + + + webView + id + + + + + IBProjectSource + PBStashContentController.h + + + + PBViewController + NSViewController + + refresh: + id + + + refresh: + + refresh: + id + + + + IBProjectSource + PBViewController.h + + + + PBWebCommitController + PBWebController + + contextMenuDelegate + id + + + contextMenuDelegate + + contextMenuDelegate + id + + + + IBProjectSource + PBWebCommitController.h + + + + PBWebController + NSObject + + YES + + YES + repository + view + + + YES + PBGitRepository + WebView + + + + YES + + YES + repository + view + + + YES + + repository + PBGitRepository + + + view + WebView + + + + + IBProjectSource + PBWebController.h + + + + PBWebStashController + PBWebCommitController + + stashController + PBStashContentController + + + stashController + + stashController + PBStashContentController + + + + IBProjectSource + PBWebStashController.h + + + + 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 + + + + NSSplitView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSSplitView.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 + + 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; diff --git a/PBWebCommitController.h b/PBWebCommitController.h new file mode 100644 index 0000000..2d53023 --- /dev/null +++ b/PBWebCommitController.h @@ -0,0 +1,41 @@ +// +// PBWebCommitController.h +// +// Created by David Catmull on 10-06-11. +// + +#import +#import "PBWebController.h" + +#import "PBRefContextDelegate.h" + + +@class NSString; +@class PBGitCommit; + +// Displays the diff from a commit in the repository. +@interface PBWebCommitController : PBWebController { + IBOutlet id contextMenuDelegate; + + NSString* currentSha; + NSString* diff; +} + +- (void) changeContentTo: (PBGitCommit *) content; +- (void) sendKey: (NSString*) key; +- (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; +// 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; + +@property (readonly) NSString* diff; +@end diff --git a/PBWebCommitController.m b/PBWebCommitController.m new file mode 100644 index 0000000..79fb31f --- /dev/null +++ b/PBWebCommitController.m @@ -0,0 +1,361 @@ +// +// PBWebCommitController.m +// +// Created by David Catmull on 10-06-11. +// + +#import "PBWebCommitController.h" +#import "PBGitCommit.h" +#import "PBGitDefaults.h" +#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 + +// -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 + +@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 + 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 *allParents = [NSMutableArray array]; + + for (NSDictionary *item in headerItems) + if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"parent"]) + [allParents addObject:[item objectForKey:kHeaderKeyContent]]; + + NSArray *parents = [self chooseDiffParents:allParents]; + + // File Stats + NSMutableDictionary *stats = [self parseStats:details]; + + // File list + 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 + 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]; + + 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 @""; +} + +- (NSArray*) chooseDiffParents:(NSArray *)parents +{ + return parents; +} + +- (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; +} + +- (NSArray *)parseHeader:(NSString *)text +{ + NSMutableArray *result = [NSMutableArray array]; + NSArray *lines = [text componentsSeparatedByString:@"\n"]; + BOOL parsingSubject = NO; + + 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 *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]]; + + NSDictionary *content = [NSDictionary dictionaryWithObjectsAndKeys: + name, kAuthorKeyName, + email, kAuthorKeyEmail, + date, kAuthorKeyDate, + nil]; + [result addObject:[NSDictionary dictionaryWithObjectsAndKeys: + [comps objectAtIndex:0], kHeaderKeyName, + content, kHeaderKeyContent, + 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]; + + [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,[item objectForKey:kHeaderKeyName]]]; + [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: 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]; + [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]; +} + +- (PBGitRef*) refFromString:(NSString*)refString +{ + return nil; +} + +- (NSArray*) menuItemsForPath:(NSString*)path +{ + return nil; +} + +- (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]; + 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 [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 + // 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) preferencesChanged +{ + [[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil]; +} + +@end 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; diff --git a/PBWebController.m b/PBWebController.m index f6cbee9..c325d77 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 @@ -91,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; 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; } diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index 74c600f..5a99ca0 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. @@ -7,29 +7,12 @@ // #import -#import "PBWebController.h" +#import "PBWebCommitController.h" -#import "PBGitCommit.h" -#import "PBGitHistoryController.h" -#import "PBRefContextDelegate.h" +@class PBGitHistoryController; - -@class PBGitSHA; - -@interface PBWebHistoryController : PBWebController { +@interface PBWebHistoryController : PBWebCommitController { IBOutlet PBGitHistoryController* historyController; - IBOutlet id contextMenuDelegate; - - PBGitSHA* currentSha; - NSString* diff; } -- (void) changeContentTo: (PBGitCommit *) content; -- (void) sendKey: (NSString*) key; -- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges; -- (NSMutableDictionary *)parseStats:(NSString *)txt; -- (NSString *) someMethodThatReturnsSomeHashForSomeString:(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 a870c30..c08f1ed 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. @@ -8,14 +8,10 @@ #import "PBWebHistoryController.h" #import "PBGitDefaults.h" -#import "PBGitSHA.h" -#import "GLFileView.h" -#import +#import "PBGitHistoryController.h" @implementation PBWebHistoryController -@synthesize diff; - - (void) awakeFromNib { startFile = @"history"; @@ -34,279 +30,52 @@ - (void) didLoad { - currentSha = nil; + [super didLoad]; [self changeContentTo: historyController.webCommit]; } - (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]; } -- (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 string], 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]; - NSString *style=@""; - int r=0; - for(r=0;r<[refsA count];r++){ - PBGitRef *ref=[refsA objectAtIndex:r]; + 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]; - - // File Stats - NSMutableDictionary *stats=[self parseStats:details]; - - // File list - NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"-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 *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]]; - - [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; - -#ifdef DEBUG_BUILD - NSString *dom=[[[[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 someMethodThatReturnsSomeHashForSomeString: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 *) someMethodThatReturnsSomeHashForSomeString:(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 { - [historyController selectCommit:[PBGitSHA shaWithString:sha]]; + [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 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..82bef0f --- /dev/null +++ b/PBWebStashController.m @@ -0,0 +1,27 @@ +// +// 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]]; +} + +- (NSArray*) chooseDiffParents:(NSArray *)parents +{ + return [NSArray arrayWithObject:[parents lastObject]]; +} + +@end diff --git a/build_libgit2.sh b/build_libgit2.sh deleted file mode 100755 index 20d4c26..0000000 --- a/build_libgit2.sh +++ /dev/null @@ -1,56 +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 - rm -f libgit2.a - make CFLAGS="-arch i386 -arch ppc" - ranlib libgit2.a - 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 - make 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/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) { diff --git a/gitx_askpasswd_main.m b/gitx_askpasswd_main.m index 07a7dbb..6ac156c 100644 --- a/gitx_askpasswd_main.m +++ b/gitx_askpasswd_main.m @@ -9,166 +9,266 @@ #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" +// 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) { - 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 c_args[4024]; + getproclline(getppid(),c_args); + NSString *cmd=[NSString stringWithFormat:@"%@",[NSString stringWithUTF8String:c_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]; + NSString *prompt; + NSString *url; + BOOL yesno=NO; + NSArray *args=[cmd componentsSeparatedByString:@" "]; - [defaults synchronize]; + 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]; + } + } - return code; -} \ No newline at end of file + 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; +} 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); } 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 @@ - - - - - - - + + + + + + + +
diff --git a/libgit2 b/libgit2 deleted file mode 160000 index 998a7bf..0000000 --- a/libgit2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 998a7bf824c5faca0f9766c9b89bb73ec1315272