mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
PBChangedFile: Don't use cat to read file contents
This changes PBChangedFile to read in files by using NSString's stringWithContentsOfFile: method. It still uses the UTF8 encoding scheme so that we can capture binary files. This should perhaps be loosened to also allow other encodings.
This commit is contained in:
+9
-2
@@ -30,8 +30,15 @@
|
||||
|
||||
- (NSString *)unstagedChanges
|
||||
{
|
||||
if (status == NEW)
|
||||
return [PBEasyPipe outputForCommand:@"/bin/cat" withArgs:[NSArray arrayWithObject:path] inDir:[repository workingDirectory]];
|
||||
if (status == NEW) {
|
||||
NSStringEncoding encoding;
|
||||
NSError *error = nil;
|
||||
NSString *contents = [NSString stringWithContentsOfFile:[[repository workingDirectory] stringByAppendingPathComponent:path] usedEncoding:&encoding error:&error];
|
||||
if (error)
|
||||
return nil;
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", @"--", path, nil]];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user