mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Use a PBGitRevSpecifier to specify possible branches
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<string key="IBDocument.HIToolboxVersion">352.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="11"/>
|
||||
<integer value="48"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -73,9 +73,10 @@
|
||||
<reference key="NSToolbarItemPaletteLabel" ref="904399424"/>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSSearchField" key="NSToolbarItemView" id="212418890">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">265</int>
|
||||
<string key="NSFrame">{{0, 14}, {183, 22}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSSearchFieldCell" key="NSCell" id="902542524">
|
||||
<int key="NSCellFlags">343014976</int>
|
||||
@@ -171,9 +172,10 @@
|
||||
<string key="NSToolbarItemPaletteLabel">Branch</string>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSPopUpButton" key="NSToolbarItemView" id="147646927">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{0, 14}, {134, 26}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSPopUpButtonCell" key="NSCell" id="638300054">
|
||||
<int key="NSCellFlags">-2076049856</int>
|
||||
@@ -281,9 +283,10 @@
|
||||
<string key="NSToolbarItemPaletteLabel">View selector</string>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSSegmentedControl" key="NSToolbarItemView" id="1040507102">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{0, 14}, {114, 23}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSSegmentedCell" key="NSCell" id="989754672">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
@@ -1746,6 +1749,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string>ref</string>
|
||||
<string>value</string>
|
||||
<string>shortName</string>
|
||||
<string>description</string>
|
||||
</object>
|
||||
<bool key="NSEditable">YES</bool>
|
||||
<object class="_NSManagedProxy" key="_NSManagedProxy"/>
|
||||
@@ -2177,43 +2181,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<int key="connectionID">171</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">contentValues: arrangedObjects.shortName</string>
|
||||
<reference key="source" ref="147646927"/>
|
||||
<reference key="destination" ref="1002608377"/>
|
||||
<object class="NSNibBindingConnector" key="connector" id="757765970">
|
||||
<reference key="NSSource" ref="147646927"/>
|
||||
<reference key="NSDestination" ref="1002608377"/>
|
||||
<string key="NSLabel">contentValues: arrangedObjects.shortName</string>
|
||||
<string key="NSBinding">contentValues</string>
|
||||
<string key="NSKeyPath">arrangedObjects.shortName</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">209</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">selectedValue: repository.currentBranch</string>
|
||||
<reference key="source" ref="147646927"/>
|
||||
<reference key="destination" ref="1001"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="147646927"/>
|
||||
<reference key="NSDestination" ref="1001"/>
|
||||
<string key="NSLabel">selectedValue: repository.currentBranch</string>
|
||||
<string key="NSBinding">selectedValue</string>
|
||||
<string key="NSKeyPath">repository.currentBranch</string>
|
||||
<object class="NSDictionary" key="NSOptions">
|
||||
<string key="NS.key.0">NSNullPlaceholder</string>
|
||||
<string key="NS.object.0">Not on branch</string>
|
||||
</object>
|
||||
<reference key="NSPreviousConnector" ref="757765970"/>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">210</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">webView</string>
|
||||
@@ -2222,6 +2189,55 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<int key="connectionID">211</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">contentValues: arrangedObjects.description</string>
|
||||
<reference key="source" ref="147646927"/>
|
||||
<reference key="destination" ref="1002608377"/>
|
||||
<object class="NSNibBindingConnector" key="connector" id="745673781">
|
||||
<reference key="NSSource" ref="147646927"/>
|
||||
<reference key="NSDestination" ref="1002608377"/>
|
||||
<string key="NSLabel">contentValues: arrangedObjects.description</string>
|
||||
<string key="NSBinding">contentValues</string>
|
||||
<string key="NSKeyPath">arrangedObjects.description</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">212</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">selectedIndex: selectionIndex</string>
|
||||
<reference key="source" ref="147646927"/>
|
||||
<reference key="destination" ref="1002608377"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="147646927"/>
|
||||
<reference key="NSDestination" ref="1002608377"/>
|
||||
<string key="NSLabel">selectedIndex: selectionIndex</string>
|
||||
<string key="NSBinding">selectedIndex</string>
|
||||
<string key="NSKeyPath">selectionIndex</string>
|
||||
<reference key="NSPreviousConnector" ref="745673781"/>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">215</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">selectionIndexes: repository.currentBranch</string>
|
||||
<reference key="source" ref="1002608377"/>
|
||||
<reference key="destination" ref="1001"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="1002608377"/>
|
||||
<reference key="NSDestination" ref="1001"/>
|
||||
<string key="NSLabel">selectionIndexes: repository.currentBranch</string>
|
||||
<string key="NSBinding">selectionIndexes</string>
|
||||
<string key="NSKeyPath">repository.currentBranch</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">218</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -2917,7 +2933,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string>PBQLOutlineView</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{429, 794}, {616, 0}}</string>
|
||||
<string>{{451, 656}, {616, 227}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{132, 614}, {616, 0}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -2980,7 +2996,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">211</int>
|
||||
<int key="maxID">218</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
D26DC6450E782C9000C777B2 /* gitx.icns in Resources */ = {isa = PBXBuildFile; fileRef = D26DC6440E782C9000C777B2 /* gitx.icns */; };
|
||||
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; };
|
||||
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
|
||||
F53FF2050E7ABB5300389171 /* PBGitRevSpecifier.m in Sources */ = {isa = PBXBuildFile; fileRef = F53FF2040E7ABB5300389171 /* PBGitRevSpecifier.m */; };
|
||||
F561727F0E056A11001DCD79 /* diff_style.css in Resources */ = {isa = PBXBuildFile; fileRef = F561727C0E056A11001DCD79 /* diff_style.css */; };
|
||||
F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */ = {isa = PBXBuildFile; fileRef = F56173270E056ED2001DCD79 /* diffHighlighter.js */; };
|
||||
F56174570E058893001DCD79 /* PBGitTree.m in Sources */ = {isa = PBXBuildFile; fileRef = F56174560E058893001DCD79 /* PBGitTree.m */; };
|
||||
@@ -99,6 +100,8 @@
|
||||
F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = "<group>"; };
|
||||
F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBQLOutlineView.m; sourceTree = "<group>"; };
|
||||
F53EE3590E06BBA00022B925 /* CWQuickLook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CWQuickLook.h; sourceTree = "<group>"; };
|
||||
F53FF2030E7ABB5300389171 /* PBGitRevSpecifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevSpecifier.h; sourceTree = "<group>"; };
|
||||
F53FF2040E7ABB5300389171 /* PBGitRevSpecifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevSpecifier.m; sourceTree = "<group>"; };
|
||||
F561727C0E056A11001DCD79 /* diff_style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = diff_style.css; path = html/diff_style.css; sourceTree = "<group>"; };
|
||||
F56173270E056ED2001DCD79 /* diffHighlighter.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = diffHighlighter.js; path = html/diffHighlighter.js; sourceTree = "<group>"; };
|
||||
F56174550E058893001DCD79 /* PBGitTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitTree.h; sourceTree = "<group>"; };
|
||||
@@ -279,6 +282,8 @@
|
||||
F56174560E058893001DCD79 /* PBGitTree.m */,
|
||||
F5FF4E160E0829C20006317A /* PBGitRevList.h */,
|
||||
F5FF4E170E0829C20006317A /* PBGitRevList.m */,
|
||||
F53FF2030E7ABB5300389171 /* PBGitRevSpecifier.h */,
|
||||
F53FF2040E7ABB5300389171 /* PBGitRevSpecifier.m */,
|
||||
);
|
||||
name = Git;
|
||||
sourceTree = "<group>";
|
||||
@@ -454,6 +459,7 @@
|
||||
F5C6F68D0E65FF9300478D97 /* PBGitLane.m in Sources */,
|
||||
F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */,
|
||||
F5AD56790E79B78100EDAAFE /* PBCommitList.m in Sources */,
|
||||
F53FF2050E7ABB5300389171 /* PBGitRevSpecifier.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
@interface PBGitRepository : NSDocument {
|
||||
PBGitRevList* revisionList;
|
||||
NSArray* branches;
|
||||
NSString* currentBranch;
|
||||
NSIndexSet* currentBranch;
|
||||
NSDictionary* refs;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
|
||||
@property (retain) PBGitRevList* revisionList;
|
||||
@property (assign) NSArray* branches;
|
||||
@property (assign) NSString* currentBranch;
|
||||
@property (assign) NSIndexSet* currentBranch;
|
||||
@property (assign) NSDictionary* refs;
|
||||
@end
|
||||
|
||||
+12
-3
@@ -13,6 +13,7 @@
|
||||
#import "NSFileHandleExt.h"
|
||||
#import "PBEasyPipe.h"
|
||||
#import "PBGitRef.h"
|
||||
#import "PBGitRevSpecifier.h"
|
||||
|
||||
NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
|
||||
@@ -170,7 +171,7 @@ static NSString* gitPath;
|
||||
sha = [components objectAtIndex:2];
|
||||
|
||||
if ([[ref type] isEqualToString:@"head"] || [[ref type] isEqualToString:@"remote"])
|
||||
[newBranches addObject: ref];
|
||||
[newBranches addObject: [[PBGitRevSpecifier alloc] initWithRef:ref]];
|
||||
|
||||
NSMutableArray* curRefs;
|
||||
if (curRefs = [newRefs objectForKey:sha])
|
||||
@@ -185,8 +186,16 @@ static NSString* gitPath;
|
||||
- (void) readCurrentBranch
|
||||
{
|
||||
NSString* branch = [self parseSymbolicReference: @"HEAD"];
|
||||
if (branch && [branch hasPrefix:@"refs/heads/"])
|
||||
self.currentBranch = [branch substringFromIndex:11];
|
||||
if (branch && [branch hasPrefix:@"refs/heads/"]) {
|
||||
int i;
|
||||
for (i = 0; i < [branches count]; i++) {
|
||||
PBGitRevSpecifier* rev = [branches objectAtIndex:i];
|
||||
if ([rev isSimpleRef] && [[rev simpleRef] isEqualToString: branch]) {
|
||||
self.currentBranch = [NSIndexSet indexSetWithIndex:i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-11
@@ -10,6 +10,7 @@
|
||||
#import "PBGitRepository.h"
|
||||
#import "PBGitCommit.h"
|
||||
#import "PBGitGrapher.h"
|
||||
#import "PBGitRevSpecifier.h"
|
||||
|
||||
@implementation PBGitRevList
|
||||
|
||||
@@ -32,16 +33,17 @@
|
||||
// and in that case we don't have to reload the revision list.
|
||||
|
||||
// If no branch was selected, use the current HEAD
|
||||
NSString* newRef = [repository currentBranch];
|
||||
if (!newRef || [newRef isEqualToString:@""])
|
||||
newRef = @"HEAD";
|
||||
newRef = [repository parseReference:newRef];
|
||||
PBGitRevSpecifier* newRev = [[[repository branches] objectsAtIndexes: [repository currentBranch]] objectAtIndex:0];
|
||||
NSString* newSha = nil;
|
||||
|
||||
if ([newRef isEqualToString:currentRef])
|
||||
if (newRev && [newRev isSimpleRef])
|
||||
newSha = [repository parseReference:[newRev simpleRef]];
|
||||
|
||||
if ([newSha isEqualToString:currentRef])
|
||||
return;
|
||||
|
||||
currentRef = newRef;
|
||||
NSThread * commitThread = [[NSThread alloc] initWithTarget: self selector: @selector(walkRevisionList) object:nil];
|
||||
currentRef = newSha;
|
||||
NSThread * commitThread = [[NSThread alloc] initWithTarget: self selector: @selector(walkRevisionListWithSpecifier:) object:newRev];
|
||||
[commitThread start];
|
||||
}
|
||||
|
||||
@@ -52,16 +54,16 @@
|
||||
[self readCommits];
|
||||
}
|
||||
|
||||
- (void) walkRevisionList
|
||||
- (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
|
||||
{
|
||||
|
||||
NSMutableArray * newArray = [NSMutableArray array];
|
||||
NSDate* start = [NSDate date];
|
||||
NSMutableArray* arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil];
|
||||
if ([parameters count] == 0)
|
||||
[arguments addObject:currentRef];
|
||||
if (!rev)
|
||||
[arguments addObject:@"HEAD"];
|
||||
else
|
||||
[arguments addObjectsFromArray:parameters];
|
||||
[arguments addObjectsFromArray:[rev parameters]];
|
||||
|
||||
NSFileHandle* handle = [repository handleForArguments: arguments];
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// PBGitRevSpecifier.h
|
||||
// GitX
|
||||
//
|
||||
// Created by Pieter de Bie on 12-09-08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <PBGitRef.h>
|
||||
|
||||
@interface PBGitRevSpecifier : NSObject {
|
||||
NSString* description;
|
||||
NSArray* parameters;
|
||||
}
|
||||
|
||||
- (id) initWithParameters:(NSArray*) params;
|
||||
- (id) initWithRef: (PBGitRef*) ref;
|
||||
|
||||
- (BOOL) isSimpleRef;
|
||||
- (NSString*) simpleRef;
|
||||
|
||||
@property(readonly) NSString* description;
|
||||
@property(readonly) NSArray* parameters;
|
||||
@end
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// PBGitRevSpecifier.m
|
||||
// GitX
|
||||
//
|
||||
// Created by Pieter de Bie on 12-09-08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PBGitRevSpecifier.h"
|
||||
|
||||
|
||||
@implementation PBGitRevSpecifier
|
||||
|
||||
@synthesize description, parameters;
|
||||
|
||||
- (id) initWithParameters:(NSArray*) params
|
||||
{
|
||||
parameters = params;
|
||||
description = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithRef: (PBGitRef*) ref
|
||||
{
|
||||
parameters = [NSArray arrayWithObject: ref.ref];
|
||||
description = ref.shortName;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isSimpleRef
|
||||
{
|
||||
return ([parameters count] == 1 && ![[parameters objectAtIndex:0] hasPrefix:@"-"]);
|
||||
}
|
||||
|
||||
- (NSString*) simpleRef
|
||||
{
|
||||
if (![self isSimpleRef])
|
||||
return nil;
|
||||
return [parameters objectAtIndex:0];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user