Skip to content

Commit

Permalink
PBChangedFile: Don't use cat to read file contents
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pieter committed Oct 28, 2008
1 parent 41a906d commit 1d19bd6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions PBChangedFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ - (NSString *) cachedChangesAmend:(BOOL) amend

- (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]];
}
Expand Down

0 comments on commit 1d19bd6

Please sign in to comment.