Skip to content

Commit fc9e3a8

Browse files
committed
Refresh git configuration before looking for the tracking branch.
1 parent 8d0a5f8 commit fc9e3a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Classes/GTBranch.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#import "GTReference.h"
2828
#import "GTEnumerator.h"
2929
#import "GTRepository.h"
30+
#import "GTConfiguration.h"
3031
#import "GTCommit.h"
3132
#import "GTRemote.h"
3233
#import "NSError+Git.h"
@@ -175,6 +176,19 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success
175176
return self;
176177
}
177178

179+
// Refresh configuration first so that libgit2 gets any updated tracking
180+
// refs in the repository's config.
181+
GTConfiguration *configuration = [self.repository configurationWithError:error];
182+
if (configuration == nil) {
183+
if (success != NULL) *success = NO;
184+
return nil;
185+
}
186+
187+
if (![configuration refresh:error]) {
188+
if (success != NULL) *success = NO;
189+
return nil;
190+
}
191+
178192
git_reference *trackingRef = NULL;
179193
int gitError = git_branch_upstream(&trackingRef, self.reference.git_reference);
180194

0 commit comments

Comments
 (0)