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.
This commit is contained in:
Pieter de Bie
2008-10-28 23:52:34 +01:00
parent 9382cbf266
commit 41a906d715
2 changed files with 8 additions and 8 deletions
+1 -6
View File
@@ -78,14 +78,9 @@
{
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;
}
+7 -2
View File
@@ -368,9 +368,14 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
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