Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 1d19bd64dfa83def18d5271c9afef9300ef0d65e 1 parent 41a906d
@pieter authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 PBChangedFile.m
View
11 PBChangedFile.m
@@ -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]];
}
Please sign in to comment.
Something went wrong with that request. Please try again.