Skip to content

Commit 946b538

Browse files
committed
Merge pull request #115 from Uncommon/stashfix
fix to handle bad stash output
2 parents 3583a9c + 5fde8e8 commit 946b538

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 count] != 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)