@@ -793,29 +793,34 @@ - (NSString*) remoteUrl:(NSString*)remoteName
793
793
}
794
794
795
795
796
- - (void ) changeRemote : (NSString *) remoteName toURL : (NSURL *)newUrl
796
+ - (void ) changeRemote : (PBGitRef *) ref toURL : (NSURL *)newUrl ;
797
797
{
798
- int gitRetValue = 1 ;
798
+ if ((!ref) || (![ref isRemote ]))
799
+ {
800
+ return ;
801
+ }
802
+
803
+ int gitRetValue = 1 ;
799
804
NSArray *arguments;
800
805
NSString *output;
801
806
802
807
// remember the current vaild remote URL to set back, if an error occurs
803
- NSString *currentRemoteURL = [self remoteUrl: remoteName];
808
+ NSString *currentRemoteURL = [self remoteUrl: [ref remoteName ] ];
804
809
805
810
// Change the URL of the remote
806
- arguments = [NSArray arrayWithObjects: @" remote" , @" set-url" , remoteName, [newUrl path ], nil ];
811
+ arguments = [NSArray arrayWithObjects: @" remote" , @" set-url" ,[ref remoteName ] , [newUrl path ], nil ];
807
812
output = [self outputInWorkdirForArguments: arguments retValue: &gitRetValue];
808
813
809
814
// Check if the new URL is valid with fetching it
810
- arguments = [NSArray arrayWithObjects: @" fetch" , remoteName, nil ];
815
+ arguments = [NSArray arrayWithObjects: @" fetch" ,[ref remoteName ] , nil ];
811
816
output = [self outputInWorkdirForArguments: arguments retValue: &gitRetValue];
812
817
if (gitRetValue)
813
818
{
814
- NSString *message = [NSString stringWithFormat: @" There was an error changing URL from Remote %@ to %@ ." ,remoteName,[newUrl path ]];
819
+ NSString *message = [NSString stringWithFormat: @" There was an error changing URL from Remote %@ to %@ ." ,[ref remoteName ] ,[newUrl path ]];
815
820
[self .windowController showErrorSheetTitle: @" URL was not changed!" message: message arguments: arguments output: output];
816
821
817
822
// Change the URL of the remote back
818
- arguments = [NSArray arrayWithObjects: @" remote" , @" set-url" , remoteName, currentRemoteURL, nil ];
823
+ arguments = [NSArray arrayWithObjects: @" remote" , @" set-url" ,[ref remoteName ] , currentRemoteURL, nil ];
819
824
output = [self outputInWorkdirForArguments: arguments retValue: &gitRetValue];
820
825
}
821
826
}
0 commit comments