Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reload commits after doing a commit
  • Loading branch information
pieter committed Sep 28, 2008
1 parent 1f7d745 commit a2217fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions PBGitCommitController.m
Expand Up @@ -203,6 +203,7 @@ - (IBAction) commit:(id) sender
otherButton:nil
informativeTextWithFormat:@"Successfully created commit %@", commit] runModal];

repository.hasChanged = YES;
self.busy--;
[commitMessageView setString:@""];
[self refresh:self];
Expand Down
7 changes: 7 additions & 0 deletions PBGitHistoryController.m
Expand Up @@ -27,6 +27,13 @@ - (void)awakeFromNib
[commitList setIntercellSpacing:cellSpacing];
[fileBrowser setTarget:self];
[fileBrowser setDoubleAction:@selector(openSelectedFile:)];

if ([repository.currentBranch count] == 0) {
[repository reloadRefs];
[repository readCurrentBranch];
}
else
[repository lazyReload];
}

- (void) updateKeys
Expand Down
3 changes: 3 additions & 0 deletions PBGitRepository.h
Expand Up @@ -16,6 +16,7 @@ extern NSString* PBGitRepositoryErrorDomain;
PBGitRevList* revisionList;
NSWindowController *windowController;

BOOL hasChanged;
NSMutableArray* branches;
NSIndexSet* currentBranch;
NSMutableDictionary* refs;
Expand All @@ -36,6 +37,7 @@ extern NSString* PBGitRepositoryErrorDomain;
- (BOOL) reloadRefs;
- (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params;
- (BOOL) removeRef:(NSString *)ref;
- (void) lazyReload;

- (void) readCurrentBranch;
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
Expand All @@ -50,6 +52,7 @@ extern NSString* PBGitRepositoryErrorDomain;
- (id) initWithURL: (NSURL*) path;
- (void) setup;

@property (assign) BOOL hasChanged;
@property (readonly) NSWindowController *windowController;
@property (retain) PBGitRevList* revisionList;
@property (assign) NSMutableArray* branches;
Expand Down
12 changes: 11 additions & 1 deletion PBGitRepository.m
Expand Up @@ -19,7 +19,7 @@

@implementation PBGitRepository

@synthesize revisionList, branches, currentBranch, refs, windowController;
@synthesize revisionList, branches, currentBranch, refs, windowController, hasChanged;
static NSString* gitPath;

+ (void) initialize
Expand Down Expand Up @@ -220,6 +220,16 @@ - (BOOL) reloadRefs
return ret;
}

- (void) lazyReload
{
if (!hasChanged)
return;

[self reloadRefs];
[self.revisionList reload];
hasChanged = NO;
}

- (PBGitRevSpecifier*) headRef
{
NSString* branch = [self parseSymbolicReference: @"HEAD"];
Expand Down

0 comments on commit a2217fe

Please sign in to comment.