Skip to content

Commit 81dbdfc

Browse files
committed
Fixed a bug which can cause remote branch considered as local
1 parent fe891b1 commit 81dbdfc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ObjectiveGit/GTBranch.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success
193193
}
194194

195195
- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error {
196-
int result = git_branch_set_upstream(self.reference.git_reference, trackingBranch.shortName.UTF8String);
196+
int result = GIT_ENOTFOUND;
197+
if (trackingBranch.branchType == GTBranchTypeRemote) {
198+
result = git_branch_set_upstream(self.reference.git_reference, [trackingBranch.name stringByReplacingOccurrencesOfString:[GTBranch remoteNamePrefix] withString:@""].UTF8String);
199+
} else {
200+
result = git_branch_set_upstream(self.reference.git_reference, trackingBranch.shortName.UTF8String);
201+
}
197202
if (result != GIT_OK) {
198203
if (error != NULL) *error = [NSError git_errorFor:result description:@"Failed to update tracking branch for %@", self];
199204
return NO;

0 commit comments

Comments
 (0)