gitx icon indicating copy to clipboard operation
gitx copied to clipboard

Unchanged files are listed for staging

Open boxed opened this issue 14 years ago • 1 comments

Files that have been touched seem to be listed as modified even though when you click on them to get the diff nothing is displayed. This becomes really annoying after a while :P

boxed avatar Mar 11 '11 15:03 boxed

I made the following hack that seems so far to be working for me. The gist of it is that "git diff-files" returns a bunch of files that are touched but not actually changed.

diff --git a/PBGitIndex.m b/PBGitIndex.m
index e41e5e5..4b29831 100644
--- a/PBGitIndex.m
+++ b/PBGitIndex.m
@@ -507,14 +507,14 @@ - (void)indexRefreshFinished:(NSNotification *)notification
        // Unstaged files
        refreshStatus++;
        handle = [PBEasyPipe handleForCommand:[PBGitBinary path] 
-                                                                                          withArgs:[NSArray arrayWithObjects:@"diff-files", @"-z", nil]
+                                                                                          withArgs:[NSArray arrayWithObjects:@"diff", @"--name-only", @"-z", nil]
                                                                                                  inDir:[workingDirectory path]];
        [nc addObserver:self selector:@selector(readUnstagedFiles:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; 
        [handle readToEndOfFileInBackgroundAndNotify];
 
        // Staged files
        refreshStatus++;
-       handle = [PBEasyPipe handleForCommand:[PBGitBinary path] 
+    handle = [PBEasyPipe handleForCommand:[PBGitBinary path] 
                                                                 withArgs:[NSArray arrayWithObjects:@"diff-index", @"--cached", @"-z", [self parentTree], nil]
                                                                        inDir:[workingDirectory path]];
        [nc addObserver:self selector:@selector(readStagedFiles:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; 
@@ -658,20 +658,11 @@ - (NSArray *)linesFromNotification:(NSNotification *)notification
 - (NSMutableDictionary *)dictionaryForLines:(NSArray *)lines
 {
        NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:[lines count]/2];
-       
-       // Fill the dictionary with the new information. These lines are in the form of:
-       // :00000 :0644 OTHER INDEX INFORMATION
-       // Filename
-
-       NSAssert1([lines count] % 2 == 0, @"Lines must have an even number of lines: %@", lines);
-
-       NSEnumerator *enumerator = [lines objectEnumerator];
-       NSString *fileStatus;
-       while (fileStatus = [enumerator nextObject]) {
-               NSString *fileName = [enumerator nextObject];
-               [dictionary setObject:[fileStatus componentsSeparatedByString:@" "] forKey:fileName];
-       }
 
+    for (NSString* filename in lines) {
+        [dictionary setObject:[@"foo bar asd qwe c" componentsSeparatedByString:@" "] forKey:filename];
+    }
+    
        return dictionary;
 }

boxed avatar Mar 15 '11 16:03 boxed