Skip to content

Commit 76c0a97

Browse files
author
David Catmull
committed
fix to handle bad stash output
My repository somehow got into a state where "git stash list" includes an extra line with just ":", causing an uncaught exception.
1 parent 3583a9c commit 76c0a97

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Model/PBGitStash.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ @implementation PBGitStash
1919
if ((self = [super init])) {
2020
stashRawString = [stashLineFromStashListOutput retain];
2121
NSArray *lineComponents = [stashLineFromStashListOutput componentsSeparatedByString:@":"];
22+
if (lineComponents != 3) {
23+
[self release];
24+
return nil;
25+
}
2226
name = [[lineComponents objectAtIndex:0] retain];
2327
stashSourceMessage = [[[lineComponents objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
2428
message = [[[lineComponents objectAtIndex:2] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];

PBStashController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ - (void) reload {
4646
if ([stashLine length] == 0)
4747
continue;
4848
PBGitStash *stash = [[PBGitStash alloc] initWithRawStashLine:stashLine];
49-
[loadedStashes addObject:stash];
49+
if (stash != nil)
50+
[loadedStashes addObject:stash];
5051
[stash release];
5152
}
5253

0 commit comments

Comments
 (0)