@@ -118,6 +118,7 @@ + (NSURL*)baseDirForURL:(NSURL*)repositoryURL;
118
118
// this works much better.
119
119
- (BOOL )readFromURL : (NSURL *)absoluteURL ofType : (NSString *)typeName error : (NSError **)outError
120
120
{
121
+ @try {
121
122
if (![PBGitBinary path ])
122
123
{
123
124
if (outError) {
@@ -153,6 +154,14 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSEr
153
154
[self setFileURL: gitDirURL];
154
155
[self setup ];
155
156
return YES ;
157
+ } @catch (id x) {
158
+ if (outError) {
159
+ NSDictionary * userInfo = [NSDictionary dictionaryWithObject: [NSString stringWithFormat: @" An error occured while trying to open %@ .\n %@ " , [self fileURL ],x]
160
+ forKey: NSLocalizedRecoverySuggestionErrorKey ];
161
+ *outError = [NSError errorWithDomain: PBGitRepositoryErrorDomain code: 0 userInfo: userInfo];
162
+ }
163
+ return NO ;
164
+ }
156
165
}
157
166
158
167
- (void ) setup
@@ -271,6 +280,11 @@ - (void) addRef: (PBGitRef *) ref fromParameters: (NSArray *) components
271
280
else
272
281
sha = [PBGitSHA shaWithString: [components objectAtIndex: 2 ]];
273
282
283
+ if (!sha) {
284
+ NSLog (@" sha was nil...? ref=%@ , components=%@ " ,ref,components);
285
+ return ;
286
+ }
287
+
274
288
NSMutableArray * curRefs;
275
289
if ( (curRefs = [refs objectForKey: sha]) != nil )
276
290
[curRefs addObject: ref];
@@ -290,6 +304,13 @@ - (void) reloadRefs
290
304
NSString *output = [self outputForArguments: arguments];
291
305
NSArray *lines = [output componentsSeparatedByString: @" \n " ];
292
306
307
+ if ([output hasPrefix: @" fatal: " ]) {
308
+ NSLog (@" Unable to read refs!" );
309
+ NSLog (@" arguments=%@ " ,arguments);
310
+ NSLog (@" output=%@ " ,output);
311
+ @throw output;
312
+ }
313
+
293
314
for (NSString *line in lines) {
294
315
// If its an empty line, skip it (e.g. with empty repositories)
295
316
if ([line length ] == 0 )
0 commit comments