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:
Pieter de Bie
2008-10-29 00:21:15 +01:00
parent 41a906d715
commit 1d19bd64df
+9 -2
View File
@@ -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]];
}