Browse files

PBGitRepository: Don't return a ref if we error out

This fixes the -parseReference: method to return nil if
there is an error in the git call. This also simplifies
our commit controller.
  • Loading branch information...
1 parent 9382cbf commit 41a906d7159d8154924cbc81725923974c54cbff @pieter committed Oct 28, 2008
Showing with 8 additions and 8 deletions.
  1. +1 −6 PBGitCommitController.m
  2. +7 −2 PBGitRepository.m
View
7 PBGitCommitController.m
@@ -78,14 +78,9 @@ - (NSString *) parentTree
{
NSString *parent = amend ? @"HEAD^" : @"HEAD";
- NSString *a = [repository parseReference:@"HEAD^"];
-
- // TODO: parseReference should exit nil if it errors out. For
- // now, compare to "HEAD"
- if ([a isEqualToString:parent]) {
+ if (![repository parseReference:parent])
// We don't have a head ref. Return the empty tree.
return @"4b825dc642cb6eb9a060e54bf8d69288fbee4904";
- }
return parent;
}
View
9 PBGitRepository.m
@@ -368,9 +368,14 @@ - (NSString*) outputForArguments:(NSArray *)arguments inputString:(NSString *)in
retValue: ret];
}
-- (NSString*) parseReference:(NSString *)reference
+- (NSString *)parseReference:(NSString *)reference
{
- return [self outputForArguments:[NSArray arrayWithObjects: @"rev-parse", reference, nil]];
+ int ret = 1;
+ NSString *ref = [self outputForArguments:[NSArray arrayWithObjects: @"rev-parse", @"--verify", reference, nil] retValue: &ret];
+ if (ret)
+ return nil;
+
+ return ref;
}
- (NSString*) parseSymbolicReference:(NSString*) reference

0 comments on commit 41a906d

Please sign in to comment.