File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,14 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString;
249249- (NSArray *)remoteBranchesWithError : (NSError **)error ;
250250- (NSArray *)branchesWithPrefix : (NSString *)prefix error : (NSError **)error ;
251251
252+ // / Get the local and remote branches and merge them together by combining local
253+ // / branches with their remote branch, if they have one.
254+ // /
255+ // / error - The error if one occurs.
256+ // /
257+ // / Returns the branches or nil if an error occurs.
258+ - (NSArray *)branches : (NSError **)error ;
259+
252260// / List all remotes in the repository
253261// /
254262// / error - will be filled if an error occurs
Original file line number Diff line number Diff line change @@ -425,6 +425,28 @@ - (NSArray *)allBranchesWithError:(NSError **)error {
425425 return allBranches;
426426}
427427
428+ - (NSArray *)branches : (NSError **)error {
429+ NSArray *localBranches = [self localBranchesWithError: error];
430+ if (localBranches == nil ) return nil ;
431+
432+ NSMutableArray *remoteBranches = [[self remoteBranchesWithError: error] mutableCopy ];
433+ if (remoteBranches == nil ) return nil ;
434+
435+ NSMutableArray *branches = [NSMutableArray array ];
436+ for (GTBranch *branch in localBranches) {
437+ BOOL success = NO ;
438+ GTBranch *trackingBranch = [branch trackingBranchWithError: error success: &success];
439+ if (!success) continue ;
440+
441+ [remoteBranches removeObject: trackingBranch];
442+ [branches addObject: branch];
443+ }
444+
445+ [branches addObjectsFromArray: remoteBranches];
446+
447+ return branches;
448+ }
449+
428450- (NSArray *)remoteNamesWithError : (NSError **)error {
429451 git_strarray array;
430452 int gitError = git_remote_list (&array, self.git_repository );
You can’t perform that action at this time.
0 commit comments