Skip to content

Commit

Permalink
PBGitRepository: Don't return a ref if we error out
Browse files Browse the repository at this point in the history
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
pieter committed Oct 28, 2008
1 parent 9382cbf commit 41a906d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 1 addition & 6 deletions PBGitCommitController.m
Expand Up @@ -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;
}
Expand Down
9 changes: 7 additions & 2 deletions PBGitRepository.m
Expand Up @@ -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
Expand Down

0 comments on commit 41a906d

Please sign in to comment.