File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
5151@property (nonatomic , readonly , strong ) GTRepository *repository;
5252@property (nonatomic , readonly , strong ) GTReference *reference;
5353@property (nonatomic , readonly , getter =isHEAD) BOOL HEAD;
54+ @property (nonatomic , assign ) GTBranch *upstreamBranch;
5455
5556+ (NSString *)localNamePrefix ;
5657+ (NSString *)remoteNamePrefix ;
Original file line number Diff line number Diff line change @@ -156,6 +156,19 @@ - (BOOL)isHEAD {
156156 return (git_branch_is_head (self.reference .git_reference ) ? YES : NO );
157157}
158158
159+ - (GTBranch *)upstreamBranch {
160+ git_reference *git_ref;
161+ int gitError = git_branch_upstream (&git_ref, self.reference .git_reference );
162+ if (gitError != GIT_OK) return nil ;
163+
164+ GTReference *ref = [[GTReference alloc ] initWithGitReference: git_ref repository: self .repository];
165+ return [GTBranch branchWithReference: ref];
166+ }
167+
168+ - (void )setUpstreamBranch : (GTBranch *)branch {
169+ git_branch_set_upstream (self.reference .git_reference , (branch ? branch.name .UTF8String : NULL ));
170+ }
171+
159172- (NSArray *)uniqueCommitsRelativeToBranch : (GTBranch *)otherBranch error : (NSError **)error {
160173 GTEnumerator *enumerator = [self .repository enumeratorForUniqueCommitsFromOID: self .OID relativeToOID: otherBranch.OID error: error];
161174 return [enumerator allObjectsWithError: error];
You can’t perform that action at this time.
0 commit comments