Make the gitx arguments "--all" and "--local" (new) switch to the corresponding branch filtered output instead of adding the argument name to the "OTHERS" group.

This commit is contained in:
André Berg
2010-03-26 11:36:06 +01:00
parent 50185248c7
commit f0a3502c72
3 changed files with 36 additions and 12 deletions
+2 -2
View File
@@ -16,10 +16,10 @@
@property (retain) NSConnection* connection;
@end
#define ConnectionName @"GitX DO Connection"
#define PBDOConnectionName @"GitXDOConnection"
#define PBCLIProxyErrorDomain @"PBCLIProxyErrorDomain"
@protocol GitXCliToolProtocol
- (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
- (BOOL)openRepository:(NSString *)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
- (void)openDiffWindowWithDiff:(NSString *)diff;
@end
+29 -6
View File
@@ -23,18 +23,27 @@
connection = [NSConnection new];
[connection setRootObject:self];
if ([connection registerName:ConnectionName] == NO)
if ([connection registerName:PBDOConnectionName] == NO)
NSBeep();
}
return self;
}
- (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
- (BOOL)openRepository:(NSString *)repositoryPath arguments: (NSArray*) args error:(NSError**)error
{
// FIXME I found that creating this redundant NSURL reference was necessary to
// work around an apparent bug with GC and Distributed Objects
// I am not familiar with GC though, so perhaps I was doing something wrong.
NSURL* url = [NSURL fileURLWithPath:[repositoryPath path]];
// !!! Andre Berg 20100326: This is because NSURL objects are passed by reference
// See NSObject's implementation of -replacementObjectForPortCoder: where it says
// "Subclasses that want to be passed by copy instead of by reference must override
// this method and return self."
// In other words we either make a subclass of NSURL that returns self for that implementation
// or we simply pass the path as NSString which is always bycopy.
// See also http://jens.mooseyard.com/2009/07/the-subtle-dangers-of-distributed-objects/#comment-3068
//
NSURL* url = [NSURL fileURLWithPath:repositoryPath isDirectory:YES];
NSArray* arguments = [NSArray arrayWithArray:args];
PBGitRepository *document = [[PBRepositoryDocumentController sharedDocumentController] documentForLocation:url];
@@ -62,9 +71,23 @@
[[arguments objectAtIndex:0] isEqualToString:@"-c"]))
[document.windowController showCommitView:self];
else {
PBGitRevSpecifier* rev = [[PBGitRevSpecifier alloc] initWithParameters:arguments];
rev.workingDirectory = url;
document.currentBranch = [document addBranch: rev];
PBGitRevSpecifier* rev = nil;
if ([arguments count] > 0 && [[arguments objectAtIndex:0] isEqualToString:@"--all"]) {
document.currentBranchFilter = kGitXAllBranchesFilter;
[document readCurrentBranch];
rev = document.currentBranch;
} else if ([arguments count] > 0 && [[arguments objectAtIndex:0] isEqualToString:@"--local"]) {
document.currentBranchFilter = kGitXLocalRemoteBranchesFilter;
[document readCurrentBranch];
rev = document.currentBranch;
}
if (!rev) {
rev = [[PBGitRevSpecifier alloc] initWithParameters:arguments];
rev.workingDirectory = url;
document.currentBranch = [document addBranch: rev];
}
[document.windowController showHistoryView:self];
}
[NSApp activateIgnoringOtherApps:YES];
+5 -4
View File
@@ -12,7 +12,7 @@
NSDistantObject* connect()
{
id proxy = [NSConnection rootProxyForConnectionWithRegisteredName:ConnectionName host:nil];
id proxy = [NSConnection rootProxyForConnectionWithRegisteredName:PBDOConnectionName host:nil];
[proxy setProtocolForProxy:@protocol(GitXCliToolProtocol)];
return proxy;
}
@@ -59,6 +59,7 @@ void usage(char const *programName)
printf("\tSee 'man git-log' and 'man git-rev-list' for options you can pass to gitx\n");
printf("\n");
printf("\t--all show all branches\n");
printf("\t--local show local branches\n");
printf("\t<branch> show specific branch\n");
printf("\t -- <path> show commits touching paths\n");
exit(1);
@@ -148,13 +149,13 @@ int main(int argc, const char** argv)
handleDiffWithArguments([arguments subarrayWithRange:NSMakeRange(1, [arguments count] - 1)], pwd, proxy);
// No diff, just open the current dir
NSURL* url = [NSURL fileURLWithPath:pwd];
NSError* error = nil;
if (![proxy openRepository:url arguments: arguments error:&error]) {
fprintf(stderr, "Error opening repository at %s\n", [[url path] UTF8String]);
if (![proxy openRepository:pwd arguments: arguments error:&error]) {
fprintf(stderr, "Error opening repository at %s\n", [pwd UTF8String]);
if (error)
fprintf(stderr, "\t%s\n", [[error localizedFailureReason] UTF8String]);
return 1;
}
return 0;