Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GitIndex: explicitly tell when stuff is updated

  • Loading branch information...
commit 029b42c5401a868078271132c49b813928e398ce 1 parent 9b1fcd7
@pieter authored
View
11 PBGitCommitController.m
@@ -18,6 +18,7 @@ - (void)commitStatusUpdated:(NSNotification *)notification;
- (void)commitFinished:(NSNotification *)notification;
- (void)commitFailed:(NSNotification *)notification;
- (void)amendCommit:(NSNotification *)notification;
+- (void)indexChanged:(NSNotification *)notification;
@end
@implementation PBGitCommitController
@@ -37,6 +38,7 @@ - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGit
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFinished:) name:PBGitIndexFinishedCommit object:index];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFailed:) name:PBGitIndexCommitFailed object:index];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(amendCommit:) name:PBGitIndexAmendMessageAvailable object:index];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(indexChanged:) name:PBGitIndexIndexUpdated object:index];
return self;
}
@@ -55,6 +57,9 @@ - (void)awakeFromNib
[[NSSortDescriptor alloc] initWithKey:@"path" ascending:true], nil]];
[cachedFilesController setSortDescriptors:[NSArray arrayWithObject:
[[NSSortDescriptor alloc] initWithKey:@"path" ascending:true]]];
+
+ [cachedFilesController setAutomaticallyRearrangesObjects:NO];
+ [unstagedFilesController setAutomaticallyRearrangesObjects:NO];
}
- (void) removeView
@@ -164,5 +169,9 @@ - (void)amendCommit:(NSNotification *)notification
commitMessageView.string = message;
}
-
+- (void)indexChanged:(NSNotification *)notification
+{
+ [cachedFilesController rearrangeObjects];
+ [unstagedFilesController rearrangeObjects];
+}
@end
View
5 PBGitIndex.h
@@ -15,11 +15,16 @@ extern NSString *PBGitIndexIndexRefreshStatus;
extern NSString *PBGitIndexIndexRefreshFailed;
extern NSString *PBGitIndexFinishedIndexRefresh;
+// The "Files" array has changed
+extern NSString *PBGitIndexIndexUpdated;
+
extern NSString *PBGitIndexCommitStatus;
extern NSString *PBGitIndexCommitFailed;
extern NSString *PBGitIndexFinishedCommit;
extern NSString *PBGitIndexAmendMessageAvailable;
+
+
// Represents a git index for a given work tree.
// As a single git repository can have multiple trees,
// the tree has to be given explicitly, even though
View
21 PBGitIndex.m
@@ -17,6 +17,8 @@
NSString *PBGitIndexIndexRefreshFailed = @"PBGitIndexIndexRefreshFailed";
NSString *PBGitIndexFinishedIndexRefresh = @"PBGitIndexFinishedIndexRefresh";
+NSString *PBGitIndexIndexUpdated = @"GBGitIndexIndexUpdated";
+
NSString *PBGitIndexCommitStatus = @"PBGitIndexCommitStatus";
NSString *PBGitIndexCommitFailed = @"PBGitIndexCommitFailed";
NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit";
@@ -45,6 +47,7 @@ @interface PBGitIndex ()
- (NSString *) parentTree;
- (void)postCommitUpdate:(NSString *)update;
- (void)postCommitFailure:(NSString *)reason;
+- (void)postIndexChange;
@end
@implementation PBGitIndex
@@ -257,13 +260,13 @@ - (BOOL)stageFiles:(NSArray *)stageFiles
return NO;
}
- // TODO: Stop Tracking
for (PBChangedFile *file in stageFiles)
{
file.hasUnstagedChanges = NO;
file.hasStagedChanges = YES;
}
- // TODO: Resume tracking
+
+ [self postIndexChange];
return YES;
}
@@ -288,14 +291,13 @@ - (BOOL)unstageFiles:(NSArray *)unstageFiles
return NO;
}
- // TODO: stop tracking
for (PBChangedFile *file in unstageFiles)
{
file.hasUnstagedChanges = YES;
file.hasStagedChanges = NO;
}
- // TODO: resume tracking
+ [self postIndexChange];
return YES;
}
@@ -353,6 +355,11 @@ - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines
return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-files", parameter, @"--", file.path, nil]];
}
+- (void)postIndexChange
+{
+ [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexIndexUpdated
+ object:self];
+}
# pragma mark WebKit Accessibility
@@ -568,8 +575,10 @@ - (NSMutableDictionary *)dictionaryForLines:(NSArray *)lines
- (void)indexStepComplete
{
// if we're still busy, do nothing :)
- if (--refreshStatus)
+ if (--refreshStatus) {
+ [self postIndexChange];
return;
+ }
// At this point, all index operations have finished.
// We need to find all files that don't have either
@@ -590,6 +599,8 @@ - (void)indexStepComplete
[[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexFinishedIndexRefresh
object:self];
+ [self postIndexChange];
+
}
@end
View
22 PBGitIndexController.m
@@ -13,11 +13,6 @@
#define FileChangesTableViewType @"GitFileChangedType"
-@interface PBGitIndexController (PrivateMethods)
-- (void)stopTrackingIndex;
-- (void)resumeTrackingIndex;
-@end
-
@implementation PBGitIndexController
- (void)awakeFromNib
@@ -67,6 +62,8 @@ - (void) ignoreFiles:(NSArray *)files
[ignoreFile writeToFile:gitIgnoreName atomically:YES encoding:enc error:&error];
if (error)
[[commitController.repository windowController] showErrorSheet:error];
+
+ // TODO: Post index change
}
# pragma mark Displaying diffs
@@ -97,6 +94,8 @@ - (void)discardChangesForFiles:(NSArray *)files force:(BOOL)force
for (PBChangedFile *file in files)
file.hasUnstagedChanges = NO;
+
+ // TODO: Post index update
}
# pragma mark Context Menu methods
@@ -316,17 +315,4 @@ + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
return NO;
}
-#pragma mark Private Methods
-- (void)stopTrackingIndex
-{
- [stagedFilesController setAutomaticallyRearrangesObjects:NO];
- [unstagedFilesController setAutomaticallyRearrangesObjects:NO];
-}
-- (void)resumeTrackingIndex
-{
- [stagedFilesController setAutomaticallyRearrangesObjects:YES];
- [unstagedFilesController setAutomaticallyRearrangesObjects:YES];
- [stagedFilesController rearrangeObjects];
- [unstagedFilesController rearrangeObjects];
-}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.