Skip to content

Commit ce7b34c

Browse files
committed
Watch both the index and working directories
#244
1 parent 5d9d113 commit ce7b34c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Classes/git/PBGitRepositoryWatcher.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ void PBGitRepositoryWatcherCallback(ConstFSEventStreamRef streamRef,
3434
NSMutableArray *changePaths = [[NSMutableArray alloc] init];
3535
NSArray *eventPaths = (__bridge NSArray*)_eventPaths;
3636
for (int i = 0; i < numEvents; ++i) {
37-
// NSLog(@"FSEvent Watcher: %@ Change %llu in %s, flags %lu", watcher, eventIds[i], paths[i], eventFlags[i]);
3837
NSString *path = [eventPaths objectAtIndex:i];
3938
if ([path hasSuffix:@".lock"]) {
4039
continue;
@@ -62,8 +61,17 @@ - (id) initWithRepository:(PBGitRepository *)theRepository {
6261
repository = theRepository;
6362
FSEventStreamContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};
6463

65-
NSString *path = [repository.fileURL path];
66-
NSArray *paths = [NSArray arrayWithObject: path];
64+
NSString *indexPath = repository.gtRepo.gitDirectoryURL.path;
65+
if (!indexPath) {
66+
return nil;
67+
}
68+
NSString *workDir = repository.gtRepo.isBare ? nil : repository.gtRepo.fileURL.path;
69+
NSArray *paths = nil;
70+
if (workDir) {
71+
paths = @[indexPath, workDir];
72+
} else {
73+
paths = @[indexPath];
74+
}
6775

6876
self.statusCache = [NSMutableDictionary new];
6977

0 commit comments

Comments
 (0)