@@ -905,7 +905,7 @@ - (BOOL) deleteRef:(PBGitRef *)ref
905
905
906
906
#pragma mark GitX Scripting
907
907
908
- - (void )handleRevListArguments : (NSArray *)arguments
908
+ - (void )handleRevListArguments : (NSArray *)arguments inWorkingDirectory : ( NSURL *) workingDirectory
909
909
{
910
910
if (![arguments count ])
911
911
return ;
@@ -915,19 +915,23 @@ - (void)handleRevListArguments:(NSArray *)arguments
915
915
// the argument may be a branch or tag name but will probably not be the full reference
916
916
if ([arguments count ] == 1 ) {
917
917
PBGitRef *refArgument = [self refForName: [arguments lastObject ]];
918
- if (refArgument)
918
+ if (refArgument) {
919
919
revListSpecifier = [[PBGitRevSpecifier alloc ] initWithRef: refArgument];
920
+ revListSpecifier.workingDirectory = workingDirectory;
921
+ }
920
922
}
921
923
922
- if (!revListSpecifier)
924
+ if (!revListSpecifier) {
923
925
revListSpecifier = [[PBGitRevSpecifier alloc ] initWithParameters: arguments];
926
+ revListSpecifier.workingDirectory = workingDirectory;
927
+ }
924
928
925
929
self.currentBranch = [self addBranch: revListSpecifier];
926
930
[PBGitDefaults setShowStageView: NO ];
927
931
[self .windowController showHistoryView: self ];
928
932
}
929
933
930
- - (void )handleBranchFilterEventForFilter : (PBGitXBranchFilterType)filter additionalArguments : (NSMutableArray *)arguments
934
+ - (void )handleBranchFilterEventForFilter : (PBGitXBranchFilterType)filter additionalArguments : (NSMutableArray *)arguments inWorkingDirectory : ( NSURL *) workingDirectory
931
935
{
932
936
self.currentBranchFilter = filter;
933
937
[PBGitDefaults setShowStageView: NO ];
@@ -936,11 +940,11 @@ - (void)handleBranchFilterEventForFilter:(PBGitXBranchFilterType)filter addition
936
940
// treat any additional arguments as a rev-list specifier
937
941
if ([arguments count ] > 1 ) {
938
942
[arguments removeObjectAtIndex: 0 ];
939
- [self handleRevListArguments: arguments];
943
+ [self handleRevListArguments: arguments inWorkingDirectory: workingDirectory ];
940
944
}
941
945
}
942
946
943
- - (void )handleGitXScriptingArguments : (NSAppleEventDescriptor *)argumentsList
947
+ - (void )handleGitXScriptingArguments : (NSAppleEventDescriptor *)argumentsList inWorkingDirectory : ( NSURL *) workingDirectory
944
948
{
945
949
NSMutableArray *arguments = [NSMutableArray array ];
946
950
uint argumentsIndex = 1 ; // AppleEvent list descriptor's are one based
@@ -964,22 +968,22 @@ - (void)handleGitXScriptingArguments:(NSAppleEventDescriptor *)argumentsList
964
968
}
965
969
966
970
if ([firstArgument isEqualToString: @" --all" ]) {
967
- [self handleBranchFilterEventForFilter: kGitXAllBranchesFilter additionalArguments: arguments];
971
+ [self handleBranchFilterEventForFilter: kGitXAllBranchesFilter additionalArguments: arguments inWorkingDirectory: workingDirectory ];
968
972
return ;
969
973
}
970
974
971
975
if ([firstArgument isEqualToString: @" --local" ]) {
972
- [self handleBranchFilterEventForFilter: kGitXLocalRemoteBranchesFilter additionalArguments: arguments];
976
+ [self handleBranchFilterEventForFilter: kGitXLocalRemoteBranchesFilter additionalArguments: arguments inWorkingDirectory: workingDirectory ];
973
977
return ;
974
978
}
975
979
976
980
if ([firstArgument isEqualToString: @" --branch" ]) {
977
- [self handleBranchFilterEventForFilter: kGitXSelectedBranchFilter additionalArguments: arguments];
981
+ [self handleBranchFilterEventForFilter: kGitXSelectedBranchFilter additionalArguments: arguments inWorkingDirectory: workingDirectory ];
978
982
return ;
979
983
}
980
984
981
985
// if the argument is not a known command then treat it as a rev-list specifier
982
- [self handleRevListArguments: arguments];
986
+ [self handleRevListArguments: arguments inWorkingDirectory: workingDirectory ];
983
987
}
984
988
985
989
// see if the current appleEvent has the command line arguments from the gitx cli
@@ -996,9 +1000,10 @@ - (void)showWindows
996
1000
// on app launch there may be many repositories opening, so double check that this is the right repo
997
1001
NSString *path = [[eventRecord paramDescriptorForKeyword: typeFileURL] stringValue ];
998
1002
if (path) {
999
- if ([[PBGitRepository gitDirForURL: [NSURL URLWithString: path]] isEqual: [self fileURL ]]) {
1003
+ NSURL *workingDirectory = [NSURL URLWithString: path];
1004
+ if ([[PBGitRepository gitDirForURL: workingDirectory] isEqual: [self fileURL ]]) {
1000
1005
NSAppleEventDescriptor *argumentsList = [eventRecord paramDescriptorForKeyword: kGitXAEKeyArgumentsList ];
1001
- [self handleGitXScriptingArguments: argumentsList];
1006
+ [self handleGitXScriptingArguments: argumentsList inWorkingDirectory: workingDirectory ];
1002
1007
1003
1008
// showWindows may be called more than once during app launch so remove the CLI data after we handle the event
1004
1009
[currentAppleEvent removeDescriptorWithKeyword: keyAEPropData];
0 commit comments