Guest User

Untitled

a guest
May 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. diff --git a/PBEasyPipe.h b/PBEasyPipe.h
  2. index 8b15646..03b80b9 100644
  3. --- a/PBEasyPipe.h
  4. +++ b/PBEasyPipe.h
  5. @@ -12,6 +12,7 @@
  6. @interface PBEasyPipe : NSObject {
  7.  
  8. }
  9. ++ (NSTask *) taskForCommand:(NSString *)cmd withArgs:(NSArray *)args inDir:(NSString *)dir;
  10.  
  11. + (NSFileHandle*) handleForCommand: (NSString*) cmd withArgs: (NSArray*) args;
  12. + (NSFileHandle*) handleForCommand: (NSString*) cmd withArgs: (NSArray*) args inDir: (NSString*) dir;
  13. diff --git a/PBEasyPipe.m b/PBEasyPipe.m
  14. index 1fe7f37..45d1fc6 100644
  15. --- a/PBEasyPipe.m
  16. +++ b/PBEasyPipe.m
  17. @@ -106,7 +106,8 @@ + (NSString*) outputForCommand: (NSString*) cmd withArgs: (NSArray*) args inDir
  18.  
  19. NSData* data = [handle readDataToEndOfFile];
  20. NSString* string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  21. -
  22. +
  23. + [task waitUntilExit];
  24. // Strip trailing newline
  25. if ([string hasSuffix:@"\n"])
  26. string = [string substringToIndex:[string length]-1];
  27. diff --git a/PBGitCommit.m b/PBGitCommit.m
  28. index 8e9a50d..30481f8 100644
  29. --- a/PBGitCommit.m
  30. +++ b/PBGitCommit.m
  31. @@ -40,8 +40,7 @@ - (NSString*) details
  32. if (details != nil)
  33. return details;
  34.  
  35. - NSFileHandle* handle = [self.repository handleForCommand:[@"show --pretty=raw " stringByAppendingString:self.sha]];
  36. - details = [[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding: NSUTF8StringEncoding];
  37. + details = [self.repository outputForArguments:[NSArray arrayWithObjects:@"show", @"--pretty=raw", self.sha, nil]];
  38.  
  39. return details;
  40. }
  41. diff --git a/PBGitRevList.m b/PBGitRevList.m
  42. index 0f1a969..8bd1fcf 100644
  43. --- a/PBGitRevList.m
  44. +++ b/PBGitRevList.m
  45. @@ -88,7 +88,9 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
  46. if ([rev hasPathLimiter])
  47. [arguments insertObject:@"--children" atIndex:1];
  48.  
  49. - NSFileHandle* handle = [repository handleForArguments: arguments];
  50. + NSTask *task = [PBEasyPipe taskForCommand:[PBGitBinary path] withArgs:arguments inDir:nil];
  51. + [task launch];
  52. + NSFileHandle* handle = [task.standardOutput fileHandleForReading];
  53.  
  54. int fd = [handle fileDescriptor];
  55. FILE* f = fdopen(fd, "r");
  56. @@ -153,6 +155,7 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
  57.  
  58. // Make sure the commits are stored before exiting.
  59. [self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:YES];
  60. + [task waitUntilExit];
  61. }
  62.  
  63. @end
Add Comment
Please, Sign In to add comment