mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
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:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user