File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,15 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
7979// / found, returns nil and sets `success` to YES.
8080- (GTBranch *)trackingBranchWithError : (NSError **)error success : (BOOL *)success ;
8181
82+ // / Update the tracking branch.
83+ // /
84+ // / trackingBranch - The tracking branch for the receiver. If nil, it unsets the
85+ // / tracking branch.
86+ // / error - The error if one occurred.
87+ // /
88+ // / Returns whether it was successful.
89+ - (BOOL )updateTrackingBranch : (GTBranch *)trackingBranch error : (NSError **)error ;
90+
8291// / Reloads the branch's reference and creates a new branch based off that newly
8392// / loaded reference.
8493// /
Original file line number Diff line number Diff line change @@ -205,6 +205,16 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success
205205 return [[self class ] branchWithReference: [[GTReference alloc ] initWithGitReference: trackingRef repository: self .repository] repository: self .repository];
206206}
207207
208+ - (BOOL )updateTrackingBranch : (GTBranch *)trackingBranch error : (NSError **)error {
209+ int result = git_branch_set_upstream (self.reference .git_reference , trackingBranch.name .UTF8String );
210+ if (result != GIT_OK) {
211+ if (error != NULL ) *error = [NSError git_errorFor: result description: @" Failed to update tracking branch for %@ " , self ];
212+ return NO ;
213+ }
214+
215+ return YES ;
216+ }
217+
208218- (GTBranch *)reloadedBranchWithError : (NSError **)error {
209219 GTReference *reloadedRef = [self .reference reloadedReferenceWithError: error];
210220 if (reloadedRef == nil ) return nil ;
You can’t perform that action at this time.
0 commit comments